• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Trouble Excluding Categories on a Blog Page

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Trouble Excluding Categories on a Blog Page

This topic is: not resolved

Tagged: blog, categories, exclude

  • This topic has 2 replies, 2 voices, and was last updated 11 years, 5 months ago by swc.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • December 25, 2013 at 2:28 pm #81191
    swc
    Member

    I need to exclude posts from certain categories on a post archive page. I'm using the blog page temple and all the posts show just fine. However, I want to exclude posts from the default Blog category. I'm attempting to do this using a filter on pre_get_posts that has the following line:

    $query->set('cat', '-1');

    However, those posts continue to be included in the posts listed. Is there something I'm missing that's causing Genesis to reset the category filter and include all posts? I'm doing this in a child theme. Is there another way I should be doing this?

    http://samuelclough.com/resource-library
    December 25, 2013 at 3:28 pm #81194
    emasai
    Participant

    This is a piece of code by Brad Dalton that I have used to remove categories from showing:

    //Exclude Posts In Category From Displaying On Blog Page Template 
    add_action( 'pre_get_posts', 'remove_posts_in_category_on_blog' );
    /**
    * @author Brad Dalton - WP Sites 
    * @example http://wpsites.net/web-design/exclude-category-posts-page/ 
    */
    function remove_posts_in_category_on_blog( $query ) {
    	
    	global $wp_the_query;
    	if( $wp_the_query === $query && $query->is_page('blog') ) {
    		$query->set( 'cat', '-007' );
    	}
     
    }

    Need Website Customization or a Responsive CSS fix? Contact Me
    Lynne emasai.com

    January 5, 2014 at 9:42 am #83373
    swc
    Member

    In case anyone else has this problem, I found that because I was using the Genesis blog page template it actually overrides this because it specifically includes the blog category which is the one I was trying to exclude. The easiest solution is to simply add a custom field with the key query_args and the value cat=-1 (or whatever other category you want to eliminate).

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble