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 11 replies, has 4 voices, and was last updated by  IanFJ 1 year, 1 month ago.

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

    IanFJ
    Participant
    Post count: 5

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

    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: 7438
    #21568

    IanFJ
    Participant
    Post count: 5

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

    Shuts down your primary sidebar?


    WordPress Developer & Consultant
    Brad Dalton400+ StudioPress Tutorials & 1200+ Code snippets

    #21579

    IanFJ
    Participant
    Post count: 5

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

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

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

    Bill,

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

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

You must be logged in to reply to this topic.