• I’m using a child theme of Twenty Eleven 1.3 and I want to show only specific post categories on the blog page, the home page and another “static” page.

    I’ve found this code which seems helpful:

    function exclude_category( $query ) {
        if ( $query->is_home ) {
            $query->set( 'cat', '-15,-48' );
        }
    }
    add_action( 'pre_get_posts', 'exclude_category' );

    However my questions are:

    – What do I insert instead of “is_home” so the code works on a static page (which is called Portfolio, if that helps) and the blog/posts page?

    – The code above excludes categories. What do I change if I want to SHOW specific categories?

    Thanks!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Showing specific categories on specific pages in Twenty Eleven’ is closed to new replies.