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

Community Forums Forums General Discussion How to Exclude the Posts of a Specific Category from the Homepage?

This topic is: not resolved

This topic contains 14 replies, has 6 voices, and was last updated by  IanFJ 2 weeks, 4 days ago.

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #20456

    IanFJ
    Participant
    Post count: 6

    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

    #20984

    cdils
    Participant
    Post count: 420

    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 tweet @cdils.

    #21007

    Bill Murray
    Participant
    Post count: 572

    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: http://wpperform.com or Twitter: @wpperform

    We do managed WordPress hosting.

    #21024

    braddalton
    Participant
    Post count: 8896

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


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #21568

    IanFJ
    Participant
    Post count: 6

    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!

    #21571

    braddalton
    Participant
    Post count: 8896

    Shuts down your primary sidebar?


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #21579

    IanFJ
    Participant
    Post count: 6

    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…

    #21585

    IanFJ
    Participant
    Post count: 6

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

    #21740

    Bill Murray
    Participant
    Post count: 572

    @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: http://wpperform.com or Twitter: @wpperform

    We do managed WordPress hosting.

    #21822

    IanFJ
    Participant
    Post count: 6

    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.

    #21885

    Bill Murray
    Participant
    Post count: 572

    @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: http://wpperform.com or Twitter: @wpperform

    We do managed WordPress hosting.

    #22775

    IanFJ
    Participant
    Post count: 6

    Bill,

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

    #112885

    wyattwerner
    Participant
    Post count: 16

    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)

    #112920

    gigamedia
    Member
    Post count: 3

    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 :)

    #114201

    IanFJ
    Participant
    Post count: 6

    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.

Viewing 15 posts - 1 through 15 (of 15 total)

You must be logged in to reply to this topic.