Search code examples
wordpressgenesis

How to remove category post from Archive page in Genesis Wordpress


The article element are the post in that category[service], my question is aside from display:none; the article, how to remove those post in category page in Genesis Wordpress using genesis way or hooks.

enter image description here


Solution

  • In Genesis you should be able to go to Genesis > Theme Settings and under Blog Page Template you can exclude posts from the blog page based on the ID.

    If your child theme doesn't support that option of you just want a solution that is more generalized, here's some code that's not Genesis specific - add this to your functions.php file. It will check to make sure it's the main post query on am archive page before running. Just replace 100 with the category ID you want removed (make sure to keep the minus sign)

    <?php
        add_action( 'pre_get_posts', 'marky939_remove_cat' );
        function marky939_remove_cat( $query ){
            if( is_archive() && $query->is_main_query() ){
                // Replace "100" with the ID for the Service category.
                $query->set( 'cat', '-100' );
            }
        }
    ?>