Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1225451
    Johanschack
    Participant

    Hey guys!

    I have some custom CSS and Javascript that is used for single posts. I was wondering, if its possible to make a new style sheet, that is loaded on all post sides only, instead of loading it on every single page on my site.

    I have a child theme installed, could it be a possibility, to make a new style sheet example “style-post.css” and then make it load only when you open a blog post?

    Best,
    Johan

    #1225807
    Jade
    Moderator

    Hi Johan,

    Please add this code in the functions.php:

    add_action( 'wp_enqueue_scripts', 'load_post_css' ); 
     
    function load_post_css() {
            if(is_single()) {	
    	    wp_enqueue_style( 'my-css', get_stylesheet_directory_uri() . '/style-post.css');
            }
    }

    Hope this helps.

    #1228445
    Johanschack
    Participant

    Hi,

    Do i also have to create the stylesheet first? If yes, where do i place it in my child theme?

    Thanks

    #1228545
    Thai
    Moderator

    Hi There,

    Please create a stylesheet file in the root folder of child theme: x-child/style-post.css

    Hope it helps 🙂

    #1233709
    Johanschack
    Participant

    Thanks! result was perfect.

    #1233727
    Prasant Rai
    Moderator

    You are most welcome. 🙂

  • <script> jQuery(function($){ $("#no-reply-1225451 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>