[wp-trac] [WordPress Trac] #4943: Add features to get_posts: select from multiple categories, or exclude categories

WordPress Trac wp-trac at lists.automattic.com
Mon Sep 10 05:53:32 GMT 2007


#4943: Add features to get_posts: select from multiple categories, or exclude
categories
------------------------------+---------------------------------------------
 Reporter:  johnjosephbachir  |       Owner:  anonymous 
     Type:  enhancement       |      Status:  new       
 Priority:  normal            |   Milestone:  2.4 (next)
Component:  General           |     Version:            
 Severity:  normal            |    Keywords:  has-patch 
------------------------------+---------------------------------------------
 This patch adds two features to get_posts(), while maintain backward
 compatibility with all previous invocations:

  * The category variable may be a comma-separated list, specifying
 selection of posts from multiple categories.
 {{{
 #!php
 get_posts('numberposts=5&category=1,5,6'); // get the 5 most recent posts
 from categories 1,5, and 6 (singular still works as before)
 }}}
  * The query may be inverted, so that the results are from any categories
 BUT the ones specified.
 {{{
 #!php
 get_posts('numberposts=5&category=3,4&category_exclude=1'); // get the 5
 most recent posts from all categories other than categories 3 and 4
 (singular also works)
 }}}

 I haven't thoroughly tested this code, it's more for discussion purposes
 at this point. But I'm fairly confident that it's a complete solution.

 (btw-- there is no 2.2.3 yet in the trac version menu)

-- 
Ticket URL: <http://trac.wordpress.org/ticket/4943>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list