WordPress.org

Support

Support » Plugins and Hacks » [Plugin: Post Category Only] Show category on main

[Plugin: Post Category Only] Show category on main

Viewing 1 replies (of 1 total)
  • The following code should do the trick:

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

    As you can see, I have replaced ‘cat’ with ‘category__in’. That will ensure posts from child categories aren’t displayed.

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Post Category Only] Show category on main’ is closed to new replies.