Opened 11 years ago
Closed 11 years ago
#28496 closed defect (bug) (worksforme)
get_posts ignoring 'category' parameter
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | major | Version: | 3.9.1 |
Component: | Query | Keywords: | reporter-feedback |
Focuses: | Cc: |
Description
The get_posts function is returning all posts regardless of what the 'category' parameter is set to.
This is happening using PHP 5.4.19 and WordPress 3.9.1
Another person has complained of the same problem at stackexchange:
http://wordpress.stackexchange.com/questions/136481/get-posts-ignoring-category-and-displaying-all-posts
Change History (4)
#3
@
11 years ago
- Keywords reporter-feedback added
I am unable to reproduce this with a clean WordPress 3.9.1 install, running PHP 5.4.19. I've simply added two posts, of which I placed one in a newly created category (with ID). Then, I ran
$posts = get_posts( array( 'posts_per_page' => -1, 'category' => 2 ) );
on the init
action, after which $posts
contained the single post in category 2.
Could you provide a way to reproduce the issue you're encountering?
Note: See
TracTickets for help on using
tickets.
WP_Query is affected by this issue as well and it looks like any function that uses get_posts or WP_Query is going to be having problems returning correct results when using the 'cat' or 'category' parameter.