Jump to content
Sign in to follow this  
quangtran

Show all posts EXCEPT one category

Recommended Posts

quangtran    0
quangtran

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
Kate    3
Kate

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
ricardo    0
ricardo

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

Share this post


Link to post
Share on other sites
quangtran    0
quangtran

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
cmunns    16
cmunns

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
quangtran    0
quangtran

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
quangtran    0
quangtran

*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
catrina    103
catrina

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.


Please read the docs before posting. Please do not private message me unless I ask you to.

Designer | Catrina Dulay

Founder | Catrina and Mouse

Share this post


Link to post
Share on other sites
quangtran    0
quangtran

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
catrina    103
catrina

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


Please read the docs before posting. Please do not private message me unless I ask you to.

Designer | Catrina Dulay

Founder | Catrina and Mouse

Share this post


Link to post
Share on other sites
quangtran    0
quangtran

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

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  

×