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',
);
query_posts($args);
This works if the categories are both at the root level (no parent)
Related Posts:
- Shortcode for custom query not returning results when attributes are added
- Return only Count from a wp_query request?
- Make a WP Query search match exactly the search term
- WP_Query: query posts by ids from array?
- Query WooCommerce orders where meta data does not exist
- pre_get_posts with get_posts
- author.php with ACF and CPTs
- Query Custom Meta Value with Increment
- Identify which loop you are hooking into; primary or secondary?
- Finding all results from database within 500 miles of the given latitude and longitude [closed]
- Show only oldest post by author
- How to get the posts published in last two days using WP_Query?
- Finding the next 5 posts
- Dynamically Override Fancy Title – Part II
- Transient pagination not working properly
- Can not switch the queried post in pre_get_posts hook
- view queries made?
- Pass the same object to multiple widgets in a template with one query
- Get the post permalink within the loop but without additional DB query
- List the 5 most recent child pages
- Is it possible to create a shortcode that will query a post based on taxonomies?
- What is considered a default query for the request filter?
- $wpdb insert is not work
- How to find exact match for search term in WP_Query? What is the additional string added in LIKE query in WP_Query?
- Query total number of posts
- Category attribute not working in custom shortcode
- Creating a custom search for a specific post type
- How to query a custom post type with a taxonomy filter but display post type archive page?
- Custom query for sidebar isn’t returning results
- Change query_posts to WP_Query in page but does not work
- Optional Meta Query
- Set conditional on template based on referring page slug
- Iterating through $wpdb query without using get_results for large query results
- Filter posts in category archive page by year using a dropdown
- Query posts intersecting tags and categories
- Include data from custom table in WP_Query
- How to get a query variable?
- Shortcode for latest -not expired- posts
- date_query seems to be ignored by wp_query
- Query Page Content From Theme Options?
- Better wordpress attachment query than this
- Modify Search Query if original Query gave no results
- Include current post into loop
- Is it possible to query from external database? [duplicate]
- Can’t sort custom post type by random
- Filter post query to only show direct children of category
- How to set up hierarchical relationships without using plugins / meta query
- wordpress udpate query not equal to
- Is it possible to retrieve posts depending on meta_key LIKE condition? [duplicate]
- How to convert query sql to shortcode in wordpress?
- WP_User_Query orderby meta_val_num
- WP_Query custom order and pagination
- How to get specific string in explode array?
- Unable to paginate a custom page query
- meta_query where the meta value is not the post title
- Multi-layered WP_Query
- `offset` WP_Query argument dont work via `pre_get_posts`
- Pagination of custom page with custom fields query
- Query pages created by deleted users
- Woocommerce Get Orders By Meta Value
- Exclude post from wp_query based on custom field boolean
- Get posts that match defined arrays of tags
- Move some posts to end of sort order, even if there is a sort in the wp_Query already
- How to display a post(by id) along with css in a page?
- Order posts by tags count?
- Strange results from WP_Query
- Is there a way to control both Order By and Order query parameters from one input field
- I need query_posts() to order results first by a meta value and then by post ID
- return child post if available otherwise parent post
- Search has query that will return no results
- Is my code correct?
- WP Query – Search in title or author_name
- URL to Post Archive of Custom Query
- Meta query doesn’t remove placeholder escape before query
- How can I modify standard search query to include also ACF custom fields values?
- Query by Category and Custom Field – Shortcode
- How to modify WP Query to target the first most recent post to adjust content
- orderby in WP_QUERY – Use the order from the Dashboard
- Random posts in WP_Query when searching by tag
- Ordering Posts by parent category, name ascending
- WP_Query always returning the last custom post
- How to get query results for the next page
- How to query post into a complex slider
- Loop through multiple custom fields with increasing number
- More efficient query to display posts in same sub-category?
- Combine privileged users array with my current query
- Having Trouble Running Query From Shortcode Using Tribe’s Events Plugin
- Horizontally paginate through sets of blog posts?
- How to organize a WP_Query’s list of posts by category and display category title?
- Need help setting up a search form for wordpress [duplicate]
- meta_query dates from an array
- Get WP_Query query after execution?
- Shortcode does not display pagination [duplicate]
- WordPress query very slow on +/- 300k DB entries and 7 INNER JOIN
- How to write a query-function as a query-shortcode?
- shortcode with $atts with strange results
- A Depth Like Parameter For “get_posts”
- Search query alteration not working for meta values
- Advanced Search – Is this possible?
- WP_query shortcode inside acf Repeater breaks the repeater loop