Community Forums › Forums › Archived Forums › General Discussion › How to Exclude the Posts of a Specific Category from the Homepage?
- This topic has 14 replies, 6 voices, and was last updated 8 years, 10 months ago by
IanFJ.
-
AuthorPosts
-
February 14, 2013 at 10:16 pm #20456
IanFJ
ParticipantI 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 #20984cdils
ParticipantHi 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 #21007Bill Murray
MemberCarrie 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 #21024Brad Dalton
ParticipantFebruary 19, 2013 at 11:59 pm #21568IanFJ
ParticipantCarrie & 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 #21571Brad Dalton
ParticipantFebruary 20, 2013 at 12:52 am #21579IanFJ
ParticipantYeah. 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 #21585IanFJ
ParticipantWait. I may have spoken too soon. Something else is going on and is interfering with my sidebar...
February 20, 2013 at 1:18 pm #21740Bill 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 #21822IanFJ
ParticipantSorry, 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 #21885Bill 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 #22775IanFJ
ParticipantBill,
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 #112885wyattwerner
MemberJust 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 #112920gigamedia
MemberHi 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 #114201IanFJ
ParticipantThanks 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.
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.