Community Forums › Forums › General Discussion › How to Exclude the Posts of a Specific Category from the Homepage?
This topic contains 11 replies, has 4 voices, and was last updated by IanFJ 2 months, 3 weeks ago.
-
AuthorPosts
-
February 14, 2013 at 10:16 pm #20456
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 #20984Hi 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.
February 18, 2013 at 9:48 am #21007Carrie 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.
Twitter: @wpperform
February 18, 2013 at 10:58 am #21024Or you can install a plugin http://wordpress.org/extend/plugins/remove-posts-in-category-from-homepage/
WordPress Developer & Consultant
Brad Dalton @ WP Sites – Click Here to Get Genesis Child Theme Tips Delivered.February 19, 2013 at 11:59 pm #21568Carrie & 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 #21571Shuts down your primary sidebar?
WordPress Developer & Consultant
Brad Dalton @ WP Sites – Click Here to Get Genesis Child Theme Tips Delivered.February 20, 2013 at 12:52 am #21579Yeah. 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 #21585Wait. 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@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.
Twitter: @wpperform
February 20, 2013 at 4:45 pm #21822Sorry, 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@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.
Twitter: @wpperform
February 25, 2013 at 4:32 pm #22775Bill,
How would widgetizing the bottom of my homepage deal with my issue? Will this somehow restrict the excluding to only the content posts?
-
AuthorPosts
You must be logged in to reply to this topic.