• Resolved Nic727

    (@nic727)


    Hi,

    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 :

    <head>
    </head>
    <body>
    <?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

Viewing 1 replies (of 1 total)
  • Thread Starter Nic727

    (@nic727)

    Ok nevermind, I found out you can do something similar to that

    function aurora_scripts(){
    
        wp_enqueue_script('aurora_jquery', "https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.5.1.min.js", array(), '3.5.1', true);
        wp_enqueue_script('aurora_js', get_template_directory_uri(). "/assets/js/scripts.js", array('aurora_jquery'), '1.0', true);
        
        if(is_home()){
            wp_enqueue_script('swiper_js',"https://unpkg.com/swiper/swiper-bundle.min.js", array(), '1.0', true);
        } 
    }
    • This reply was modified 3 years, 9 months ago by Nic727.
    • This reply was modified 3 years, 9 months ago by Nic727.
    • This reply was modified 3 years, 9 months ago by Nic727.
Viewing 1 replies (of 1 total)
  • The topic ‘Different stylesheet for each pages’ is closed to new replies.