• 0
Sign in to follow this  
Followers 0

Show all posts EXCEPT one category

Question

Posted · Report post

Hi, I got Platform Pro up and running, everything fine. There just one thing I need. I would like to have the homepage show all posts, EXCEPT one category (for ex. 'twitter'). query_posts( 'cat=-3' ) didn't work for me or I did a wrong implementation. Any help would be nice! Q

Share this post


Link to post
Share on other sites

11 answers to this question

  • 0

Posted · Report post

Hi quang, Can you post a little of the surrounding code? (Where you placed the query_posts call...)

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

(EDIT: Ah! Kate beat me to it =))

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

due to the fact, that I Platform Pro doesn't seem to work with 'query_posts' to build the main page, I tried to insert it into the template.postloop.php at the following line:

if(is_admin()) query_posts('showposts=1&cat=-3'); // For parsing in admin, no posts so set it to one.

So, but it seems like 'query_posts' is an dead end for my issue. Isn't there any other way to except one category for the main page?

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

that won't work. You need to add query_posts before the loop. You can do so with a hook. In your -Base functions.php file add ` add_action ('pagelines_before_theloop','exclude_cat'); function exclude_cat(){ query_posts(cat=-3); } ` Something like that.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

It worked! Except there were some apostrophes missing. Final Code for listing all categories except category ID=50 in functions.php:

<?php
	/*
	
		THEME INITIALIZATION
	
		This file loads the core framework for Platform which handles everything.
	
		This theme copyright (C) 2008-2010 PageLines
	
	*/
	
		require_once(TEMPLATEPATH . "/core/core.init.php");
	
		add_action ('pagelines_before_theloop','exclude_cat');
	
		function exclude_cat()
		{
			query_posts('cat=-50');
		}

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

*EDIT* Not solved. It now affects all sites and all category listings. How can you limit it to just the blog page (usually the home page for Platform Pro)?

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

I think it has to do with the hook that is currently in the code (pagelines_before_theloop). A different one should be used instead.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Is query_posts the correct command? I didn't find it anywhere in the code. How does Pageline Pro build the overview of the last posts?

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Those posts are generated using the loop in the template.postloop.php file.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Yes, but how do it query the Wordpress DB? I'm not that php pro.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

How can you limit it to just the blog page
you can use this for the query_posts line: `if(is_home()) query_posts('cat=-50');` some more WP conditionals you might find useful here: http://codex.wordpress.org/Conditional_Tags

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