Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#28496 closed defect (bug) (worksforme)

get_posts ignoring 'category' parameter

Reported by: ton_y's profile Ton_y 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)

#1 @Ton_y
11 years ago

  • Severity changed from normal to major

#2 @Ton_y
11 years ago

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.

Last edited 11 years ago by Ton_y (previous) (diff)

#3 @engelen
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?

#4 @wonderboymusic
11 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Steps to reproduce if still a problem - this works for me.

Note: See TracTickets for help on using tickets.