• 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

How to Exclude the Posts of a Specific Category from the Homepage?

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 › General Discussion › How to Exclude the Posts of a Specific Category from the Homepage?

This topic is: not resolved
  • This topic has 14 replies, 6 voices, and was last updated 8 years, 1 month ago by IanFJ.
Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • February 14, 2013 at 10:16 pm #20456
    IanFJ
    Participant

    I would like to exclude the posts from a specific category ("Quotes", category #7) from my homepage.  I've reserved this category to show in a sidebar widget instead.

    Searching around for ideas, one forum told me to add

    <?php if ( !is_home() OR (is_home() AND !in_category('quotes')) ) } ?>

    to  functions.php.

    Another suggested

    <?php
    if (is_home()) {
    query_posts("cat=-7");
    }
    ?>

    Neither of these suggestions work for me, unless of course I am implementing them incorrectly.

    Would anyone be willing to walk me through what I should be doing?

     

    Best regards,

    Ian

    February 18, 2013 at 7:50 am #20984
    cdils
    Participant

    Hi Ian,

    Which theme are you using? If it has a home.php in the theme folder, that's where you'll want to add in your conditional statement. Otherwise, if there is no home.php, then functions.php is where you'll be working.

    The conditional if statement needs to be in the context of an action hook. See if this might be what you're looking for? http://genesissnippets.com/genesis-custom-loop/

    Carrie

     


    Have you been helped in this forum? Pay it forward and answer someone else’s question. I bet you’ll know the answer to at least one question. 🙂

    I host a weekly WordPress-focused podcast called Office Hours. I tweet @cdils.

    February 18, 2013 at 9:48 am #21007
    Bill Murray
    Member

    Carrie is right that this is very theme dependent, but you might try visiting your Genesis settings and see the ability to exclude one or more categories from the blog page template. If your theme is using that template, as opposed to a customized home.php, that's all you need to adjust - no coding required.


    Web: https://wpperform.com or Twitter: @wpperform

    We do managed WordPress hosting.

    February 18, 2013 at 10:58 am #21024
    Brad Dalton
    Participant

    Or you can install a plugin http://wordpress.org/extend/plugins/remove-posts-in-category-from-homepage/


    Recent Client work

    February 19, 2013 at 11:59 pm #21568
    IanFJ
    Participant

    Carrie & Bill:  The theme I am using is the Streamline child theme.  It does use a specific home.php template.

    Brad: I was looking for a plugin.  There is another I tested, but, as with the one you suggested, when I 'turn off' the category I want to hide, this operation also shuts down my sidebar, since I am using that category there.  Oh well.  I was hoping for better...

    Thank you very much, all of you, for your suggestions!

    February 20, 2013 at 12:14 am #21571
    Brad Dalton
    Participant

    Shuts down your primary sidebar?


    Recent Client work

    February 20, 2013 at 12:52 am #21579
    IanFJ
    Participant

    Yeah.  Excluding a category shuts down the sidebar completely.

    I have a variety of sidebar widgets, using the Genesis eNews Extended, Featured Page, and Featured Widget Amplified plugins.  One of the widgets using Featured Posts, is displaying the posts from the category I want to exclude from the featured content on the homepage.  So, I guess excluding a category from the homepage excludes it from everywhere on the homepage.  I could work around this except that the whole sidebar gets excluded, not just the widget displaying the posts from the offending category.

    Funny, isn't it?  I'll just have to do something else...

    February 20, 2013 at 1:38 am #21585
    IanFJ
    Participant

    Wait.  I may have spoken too soon.  Something else is going on and is interfering with my sidebar...

    February 20, 2013 at 1:18 pm #21740
    Bill Murray
    Member

    @IanFJ - Give my suggestion a try. It should work with the Streamline theme. Streamline does use a home.php, but the code just checks to see if certain widget areas are active. It still relies on the standard Genesis loop. There's no need for a plugin to do what you want, as the functionality is already in the framework.


    Web: https://wpperform.com or Twitter: @wpperform

    We do managed WordPress hosting.

    February 20, 2013 at 4:45 pm #21822
    IanFJ
    Participant

    Sorry, Bill, but it doesn't work.

    The option to exclude categories is available in the settings of the Blog template, but this doesn't affect what gets displayed on my homepage.  I did try, both before and now again.  It would have been a nice solution...

    It's ok though.  There is a Random Text plugin that does the trick.  I just would have preferred having the quotes as posts, so that I could use them in other ways.

    February 20, 2013 at 11:33 pm #21885
    Bill Murray
    Member

    @IanFJ - You're right. I took another look and that setting even says it won't work on the home page. Silly me. Sorry. However, there are other ways to get what you want:

    1) See this post by Bill Erickson.

    2) Widgetize the bottom of the Streamline homepage, and then use a widget that allows you to exclude a category.


    Web: https://wpperform.com or Twitter: @wpperform

    We do managed WordPress hosting.

    February 25, 2013 at 4:32 pm #22775
    IanFJ
    Participant

    Bill,

    How would widgetizing the bottom of my homepage deal with my issue?  Will this somehow restrict the excluding to only the content posts?

    July 3, 2014 at 11:08 am #112885
    wyattwerner
    Member

    Just for the record:

    I was using this plugin recently and found that it interfered with the Featured Posts widget. I was unable to filter a Featured Posts widget by category. I.e., I wanted a Featured Posts widget to display posts from only one category, but it would only display posts from all categories. The widget was not on the home page, but a different page.

    I was using the Minimum theme (not Minimum Pro)

    July 3, 2014 at 9:22 pm #112920
    gigamedia
    Member

    Hi Ian, I tested this for you and is working for me. Although I tested in the Sixteen Nine Pro Theme, the conditional statement I used resided in the Genesis (Version: 2.0.2) parent theme under: themes/genesis/lib/structure/loops.php
    directly above:

    if ( have_posts() ) : while ( have_posts() ) : the_post();

    I added:

    if ( is_home() ) {query_posts('cat=-7');}

    And it worked. Let me know if that resolves your issue 🙂

    July 13, 2014 at 10:02 pm #114201
    IanFJ
    Participant

    Thanks gigamedia for your suggested fix.

    I believe that I ended up just using a random text box on the side, rather than a separate category for quotes.

    However, just last week, I upgraded my site to the Sixteen Nine Pro theme and have removed the quotations from the sidebar completely, opting instead for using the quote post format.

  • Author
    Posts
Viewing 15 posts - 1 through 15 (of 15 total)
  • The forum ‘General Discussion’ 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

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