Support » Fixing WordPress » get_posts() doesn’t work when category is specified

  • Resolved zimmi88


    Hi! I’m currently working on a plugin that will manage custom output for the homepage of a site I’m constructing. Unfortunately, I’m having problems with the get_posts() function.

    What I would like the code to do is loop through the categories, printing out the posts that are associated with each category and has a specific tag, as specified in the settings. However, as of now, if I specify a ‘category’ in my get_posts() query, I get back no posts. If the ‘category’ option is omitted, the function works as expected (outputs all posts with specific tag in specified order).

    I’ve tried placing my options in an array and query string. I’ve tried ‘category_name’ instead of ‘category’. Finally, I’ve tried being extremely explicit with typecasting. Sadly, all of these haven’t done anything.

    I’ve pasted the source at

    Any help anyone can provide in this matter is greatly appreciated. Thank you in advance for your help!

Viewing 1 replies (of 1 total)
  • Following up on this issue, I worked with a friend to determine that the issue is a compatibility error with get_posts(), which doesn’t seem to work when given a query that includes both a category and a tag. Given this, I have gone back and am using an alternate attribute for my queries.

Viewing 1 replies (of 1 total)
  • The topic ‘get_posts() doesn’t work when category is specified’ is closed to new replies.