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


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)


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.

  • 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) '); ?>
  • 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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