WordPress.org

Forums

Excluding Select Categories From Single Post Nav (1 post)

  1. bdp
    Member
    Posted 2 years ago #

    I used this code at the bottom of my functions.php to exclude select categories from front page:

    function exclude_category($query) {
    if ( $query->is_home ) {
    $query->set('cat', '-254');
    }
    return $query;
    }
    add_filter('pre_get_posts', 'exclude_category');

    It works perfect, the only thing is when you click on a post you can still get to that post that was supposed to excluded in the page navigation.

    For example, if you go to my homepage and click on the first post you will then see page navigation for older and newer posts. The newer post being the excluded one.

    Does anyone know how to exclude certain categories from page navigation on single posts? Please help!

    Take a look here: Los

Topic Closed

This topic has been closed to new replies.

About this Topic