[wp-hackers] Pull Latest Post from Each of 6 Categories

Paul paul at codehooligans.com
Mon May 4 22:36:28 GMT 2009


Yeah started thinking that after sending the email. After a reread my  
guess is getting the latest one post from each of the 6 categories  
regardless of post_date is not something that can be done via a single  
SQL query itself. But if someone comes up with an idea I hope they  
post it to share with others.

P-



On May 4, 2009, at 5:24 PM, Mike Schinkel wrote:

> My guess is he wants the latest posts from each category  
> individually, not just the latest posts from a list of categories.  
> That's a very different SQL statement.
>
> -Mike Schinkel
> WordPress Custom Plugins
> http://mikeschinkel.com/custom-wordpress-plugins/
>
>
>
>
> On May 4, 2009, at 6:08 PM, Paul wrote:
>
>> Nathan,
>>
>> Are you handling the display of the posts from the 6 categories in  
>> groups? Meaning are you:
>>
>> 1. Query for 6 posts in category 'A'. Display loop of items.
>> 2. Query for 6 posts in category 'B'. Display loop of items.
>> 3. Query for 6 posts in category 'C'. Display loop of items.
>> etc.
>>
>> Or is it more like Query post from category A,B,C,D,E,F. Display  
>> loop of items.
>>
>> I'm not sure why you are using 6 different WP_Query instances.
>>
>>
>> Paul
>>
>>
>> On May 4, 2009, at 4:42 PM, Nathan Rice wrote:
>>
>>> I was wondering if there are any WP_Query hackers out there who  
>>> might be
>>> able to help me achieve what I'm looking to achieve here.
>>>
>>> I have a site which has a section on the homepage that pulls the  
>>> latest post
>>> from each of 6 different categories.  As of now, I'm running 6  
>>> separate
>>> instances of WP_Query to get the latest post from each of the 6  
>>> categories.
>>>
>>> I would very much like to reduce this down to only a single query,  
>>> if
>>> possible.
>>>
>>> Is there any combination of parameters I can pass to "new  
>>> WP_Query" in order
>>> to get it to return the latest post from each of the 6 categories.
>>>
>>> If so, that would be awesome.
>>>
>>> Thanks!
>>> Nathan
>>>
>>> My Website
>>> http://www.nathanrice.net/
>>>
>>> My Twitter
>>> http://twitter.com/nathanrice
>>> _______________________________________________
>>> wp-hackers mailing list
>>> wp-hackers at lists.automattic.com
>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list