Jump to content


Photo
- - - - -

Show all posts EXCEPT one category


  • Please log in to reply
11 replies to this topic

#1 quangtran

quangtran

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 12 May 2011 - 01:48 PM

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

#2 Kate

Kate

    Advocate

  • Members
  • 3039 posts

Posted 12 May 2011 - 01:55 PM

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

#3 ricardo

ricardo

    Advocate

  • Members
  • 587 posts

Posted 12 May 2011 - 01:55 PM

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

#4 quangtran

quangtran

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 12 May 2011 - 02:20 PM

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:

Please Login or Register to see this Hidden Content


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?

#5 cmunns

cmunns

    Advocate

  • Members

  • 6537 posts
  • Country: Country Flag

Posted 12 May 2011 - 06:28 PM

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.

#6 quangtran

quangtran

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 13 May 2011 - 09:59 AM

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

Please Login or Register to see this Hidden Content



#7 quangtran

quangtran

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 13 May 2011 - 10:08 AM

*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)?

#8 catrina

catrina

    Advocate

  • Members
  • 12345 posts
  • LocationCalifornia
  • Country: Country Flag

Posted 13 May 2011 - 03:30 PM

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.

#9 quangtran

quangtran

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 13 May 2011 - 03:41 PM

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?

#10 catrina

catrina

    Advocate

  • Members
  • 12345 posts
  • LocationCalifornia
  • Country: Country Flag

Posted 13 May 2011 - 04:08 PM

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

#11 quangtran

quangtran

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 13 May 2011 - 04:09 PM

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

#12 timlinson

timlinson

    Advocate

  • Members
  • PipPipPipPipPip
  • 1032 posts

Posted 13 May 2011 - 06:50 PM

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:

Please Login or Register to see this Hidden Content