0

my question pertains to the wordpress.org platform. Recently i created a new category for my posts(called reviews) and added it as a part of the menu. Basically i wanted to send all the book reviews in to this new menu addition, rather than posting it along with all other posts in the main page. What happened is the posts with book reviews are now appearing in the main page, as well as in the newly created Reviews menu bar. I want them to appear book reviews only in the new menu bar. Can You help?

1 Answer 1

0

You can exclude posts in the "Reviews" category from the main feed using the pre_get_posts hook and some WP_Query knowledge:

add_action( 'pre_get_posts', function ( $wp_query ) {
    if ( ! is_admin() && $wp_query->is_main_query() && $wp_query->is_home() ) {
        $wp_query->set( 'category__not_in', 4 );
    }
});

Here I've assumed the ID of the category is 4, you'll need to find out what yours is.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.