Opened 18 years ago
Closed 16 years ago
#4943 closed enhancement (invalid)
Add features to get_posts: select from multiple categories, or exclude categories
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | low | |
Severity: | minor | Version: | |
Component: | Template | Keywords: | |
Focuses: | Cc: |
Description
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.
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.
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)
Attachments (1)
Change History (8)
#3
@
18 years ago
Scratch that, Sorry, It only includes/excludes based upon the Post ID's, not the categories.
But you may want to create patches/modifications based on the current 2.3(trunk) source rather than the 2.2 code branch.
Note: See
TracTickets for help on using
tickets.
The underlying code for categories has changed in 2.3
It appears that 2.3 allready has the ability to exclude/include posts based on the category
See line 199/235 here:
http://trac.wordpress.org/browser/trunk/wp-includes/post.php#L193