• 0
Sign in to follow this  
Followers 0

Need help to eliminate certain posts categories from showing up in Blog

Question

Posted · Report post

Guys, need help in excluding certain posts categories from showing up in the Blog section and "latest posts entries" widget in the StationPro theme. Ive included a query_posts( 'cat=-4' ); in the index.php of the theme (StationPro) but it works partially. Thanks...

Share this post


Link to post
Share on other sites

11 answers to this question

  • 0

Posted · Report post

Can you tell us more about the code you've used...Typically if you want to make this only affect certain pages such as the main blog then you would add conditionals e.g. ` if(is_home()): query_posts( 'cat=-4' ); endif; `

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Well, specifically Ive put the query_posts( 'cat=-4' ); in the index.php of the theme and it works when the "Blog" page is accessed. But I have 2 issues: 1. In the widget (from _morefooter) where the latest posts are shown (mine is 3, just the titles) I still see the posts from the category that is supposed to be excluded. 2. When the "Blog" page is accessed in the summary of the posts the excluded category's posts are not visible, but when each individual post is accessed then the "prev" or "next" posts might be of the excluded category. Is there a remedy for this ? Thanks...

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Thanks, but my issue is not the code its exactly where does it need to go. The widget that Im using on the homepage is the: Recent Posts I need to be able to exclude one category from showing up in the "most recent 3 posts" widget.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Can you post a link to your site? I think I confused the "Recent Posts" widget with something else, but I'm pretty sure it's the widget that lists the post link titles...

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

my issue is not the code its exactly where does it need to go
query_posts() won't affect the widgets regardless of where you put it. You can use a php exec plugin and make your own recent posts widget with some php code. This is one example: http://forum.bytesforall.com/showthread.php?t=865

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Tim, I see maybe it makes sense just to implement my own code. I thought there was a way to do it through the widget, but yeah I've tried everything and the widget was still showing the excluded Category. Now, I still see the post in the "Blog" singles pages. For instace lets say Im in a given category the "next" post might show a post from the excluded category. Do you guys know why ? Thanks...

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Yes, I've actually find the code that exclude the post from excluded categories in the single post "prev" and "next" posts in wp-includes/link-template.php function previous_post_link($format='« %link', $link='%title', $in_same_cat = false, $excluded_categories = '4') { adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, true); } /** * Display next post link that is adjacent to the current post. * * @since 1.5.0 * * @param string $format Optional. Link anchor format. * @param string $link Optional. Link permalink format. * @param bool $in_same_cat Optional. Whether link should be in same category. * @param string $excluded_categories Optional. Excluded categories IDs. */ function next_post_link($format='%link »', $link='%title', $in_same_cat = false, $excluded_categories = '4') { adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, false); } It worked for me! So now I will just have to exclude the posts from excluded categories in the Recent Posts Widget. I think I will either use an excluder plugin or right my own.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Ok, found a plugin that exclude categories from pages and widgets "ACE". I guess this is it. I got everything that I need. Thanks alot guys for your help. Thanks...

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

can you tell us what is the plugin? does it work on the posts page to exclude posts from a particular category?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0