WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

we're working on a bilingual site,

Larry A. Downs

all the posts are categorized into two categories, english or spanish, along with other categories. so every post has multiple categories,

i've coded out a shortcode that sets up a tabbed widget in the sidebar, based on the language category, using multiple WP_Query's and looping thru them,

but if you look on the english category page: /category/english

some the queries are returning posts from the spanish category, i've checked the posts and they're in the right categories, i think i'm not setting up my query $args properly, and could use the wisdom of higher lever wordpressers than i.

thanks again stack.

here's the sidebartabs shortcode: SidebarTabs Shortcode

share|improve this question
up vote 0 down vote accepted

As of WordPress 3.6 you can put comma-delimited entries in the category_name property of the arguments array like this:

$args = array(
  'category_name' => 'news2014,news2015',


This works if the categories are both at the root level (no parent)

share|improve this answer

You want to use category__and and pass an array of category ids for language and favorites or language and lifestyle.

See Category Paremeters for WP_Query in Codex.

share|improve this answer
well that makes sense. i had thought $query = new WP_Query( 'category_name=staff,news' ); would do that. apparently not. tyty. so you can't do posts in multiple categories based on category name? no worries. guess i should have read a little further down the page... thanks for the help milo! – joelrnorris Jul 24 '12 at 12:39

Explicitly defining your category names as an array works, at least as of this date and WP 3.5.1-

<?php $query = new WP_Query(' category_name=array(staff,news) '); ?>
share|improve this answer
Would be better to not use a query string to add arguments. They're officially no longer supported by WP core (while still working) and won't be implemented for newer API functions. – kaiser May 5 '13 at 23:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.