Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1283654
    twelvetwo
    Participant

    Have a unique situation where I need to exclude a post category from the blog page. Have tried a plugin that claims to do this, but with no luck.

    I’m familiar with editing template files, but having trouble isolating where exactly the theme is pulling blog posts. I realize this is out of scope for what you support, but any recommendations would be greatly appreciated.

    Thanks!

    #1284060
    Rupok
    Member

    Hi there,

    Thanks for writing in! I can help you by hiding the post from certain category with some CSS. If that’s okay for you then provide your URL and mention the category name.

    Cheers!

    #1284724
    twelvetwo
    Participant
    This reply has been marked as private.
    #1284780
    Thai
    Moderator

    Hi There,

    Please add the following code under functions.php file locates in your child theme:

    function x_exclude_cat_from_home($query) {
    	if ($query->is_home() && $query->is_main_query()) {
    		$query->set('cat', '-123');
    	}
    }
    add_action('pre_get_posts', 'x_exclude_cat_from_home');

    Replace the 123 number with your category ID.

    Hope it helps 🙂

    #1285013
    twelvetwo
    Participant

    Wow – you guys are awesome! Thank you very much. On my way to leave a 5 star review. 🙂

    #1285417
    Rad
    Moderator

    You’re so much welcome! Thank you very much 🙂

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