Different stylesheet for each pages


I’m currently looking at a tutorial how to develop my own WordPress theme.

Almost each of my pages have different functionalities that require different script or styles. However, I’m not really sure how to integrate that into my code.

For example, function.php allow me to insert stylesheet and script files with wp_footer(); and wp_head();

However, I just included the ones that will be repeated on each pages. Now I’m with the header.php part and most people include all the <head> up to the navigation… But that wouldn’t work for me since I need to add additional stylesheet to my pages.
It would be something like :

<?php get_header(); ?>

My header.php would only include the navigation and I would add other style for each pages into the <head>… But is that something that I should do or is there another solution?
I don’t want to overload my site with useless code. Like, there is a slider only appearing on the homepage and there is a filter code only appearing on my blog page.

Thank you

Source link