• 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

Exclude Category Not Working

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 › Exclude Category Not Working

This topic is: not resolved

Tagged: exclude categories

  • This topic has 5 replies, 2 voices, and was last updated 8 years, 7 months ago by Brad Dalton.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • August 7, 2017 at 8:01 pm #210097
    travisdotmedia
    Member

    Hello everyone! Are there any known issues with the 'Exclude Categories' option in the theme settings? I am trying to solve this for a client and I just can't nail it down. I can enter a manual code into functions.php to exclude a category and voila, it works. But when I put in the category ID into the Exclude Categories field in the Genesis Settings, the posts still show up. He has a homepage and a blog page and the blog page is set to the blog template (which is what is documented as how it must be set up to work).

    I thought perhaps it may be a plugin conflict on his site, but just for kicks I tried my own site to see if it worked and it also does not work on my site. I have a homepage as well as a blog page, using the blog page template. My site is Travis.Media.

    Any thoughts? Anyone else with this issue?

    http://travis.media
    August 8, 2017 at 5:06 am #210104
    Brad Dalton
    Participant

    I doubt you can use code and theme settings at the same time, also, what code are you using?


    Tutorials for StudioPress Themes.

    August 8, 2017 at 5:21 am #210106
    travisdotmedia
    Member

    Hi Brad,

    On Travis.media, I am not using any code to exclude. If I put it a category ID into the Exclude Category field, it does not seem to work.

    On the other site (patrickoben.com) I remove the code and place the ID in the field and it does not seem to exclude.

    Currently the code is in place. It is,

    add_action( 'pre_get_posts', 'exclude_category_from_blog' );
    function exclude_category_from_blog( $query ) {

    if( $query->is_main_query() && $query->is_home() ) {
    $query->set( 'cat', '-5171' );
    }
    }

    This code works. Does Genesis exclude under the same conditionals?

    August 8, 2017 at 5:32 am #210108
    Brad Dalton
    Participant

    In relation to use of the blog template, exclude category works fine when i test it however the code doesn't work with the blog template however it does work with the home page. Tested using the default reading settings which you may have changed.


    Tutorials for StudioPress Themes.

    August 8, 2017 at 6:31 am #210110
    travisdotmedia
    Member

    Thanks Brad! So I just changed my Static Front Page option in the Customizer so that the Front Page displays the latest posts and the exclude works. So this does not work on the blog pages if you set a static homepage?

    August 8, 2017 at 6:38 am #210112
    Brad Dalton
    Participant

    Yes.

    The code only works with the front page and not the blog page template.

    The theme settings only work for the blog page template.


    Tutorials for StudioPress Themes.

  • Author
    Posts
Viewing 6 posts - 1 through 6 (of 6 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

© 2026 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