Maybe this could help and should return any post either in 2, 3 or 4 category AND in categoery 1 :
query_posts( array( 'cat' => array(2,3,4), 'category__and' => 1, 'posts_per_page' => 1, 'orderby' => 'title', 'order' => 'DESC' ) );
(from codex http://codex.wordpress.org/Function_Reference/query_posts)
Not quite sure, haven’t tested it.
Related Posts:
- Alter query on edit.php
- my function doesn’t return my post from today
- Get stock by custom meta field on all Woocommerce variable products
- PHP -> SQL Query with Summing
- How to hide posts of a specific custom category in WordPress?
- Why my query does not run with prepare
- mySQL queries are executed twice on wordpress website
- Build A Custom SQL Query for WordPress Search
- Category Page Displaying all Pages
- Trying to exclude posts from a category on the home page
- Hide empty categories from get_categories
- SQL query to retrieve the number of WordPress posts with all given categories
- Exclude a category ID from the following function
- Display featured posts first, then display all others within a specific category in WordPress
- Accessing the database from a plugin outside of action hooks
- Echo a hierarchical list of post data from custom fields
- Display fields as values in array from external SQL DB
- Create WP_Query to search for posts by their categories or their parent/child categories
- WP Query with custom Shortcode
- Storing Array from returned database query and using the array in a new query
- Proper syntax or method for keeping url in modified isotope / category links
- Filter Select results based on selection
- mysql query from wordpress page using custom table
- query in category.php repeats itself
- WordPress 3.2 query_posts and pagination, permalinks issue
- Importing Geo data into wordpress database
- Detect session/cookie variable in wordpress to prevent access to documents
- only show container with next/prev links if they exist?
- What is an equivalent of single_cat_title for getting the slug of the category?
- Issue adding sub category programmatically
- What query string parameter is available for index.php, that works for both pages and blog articles?
- ACF: how do I get the fields and its values of a specific group?
- How to exclude category ID from Looper in WordPress
- Add a specific part of current category page url to shortcode
- how do I get a specific post from a post with a subcategory in WP
- WP grandchild categories in nested ul li
- Grab posts by multiple categories
- Pass Category Name, Description and Photo into variables to pass to jQuery
- Querying wpdb using PHP
- How to show single category archive
- Move category description below post list in blog
- Set WP_query ‘order’ option by another tables value
- WP_Query adds “(wp_posts.ID = ‘0’)” so no results are returned
- How to pick the default selected value in wordpress dropdown?
- Applying A Category to Existing Posts Where Page Title Matches Regex
- Get page that displays all children of taxonomy parent
- WordPress default Search function inconsistent in WooCommerce Product Titles
- Increase offset while looping
- selected option if current category is the value
- Long running queries
- wpdb php get_var query to get ID for URL image doesn’t work for ID over 999
- get_template_part based upon post’s category
- How to pre populate a form field with a link of a current user’s author profile?
- how to save selected option in variable for rest api category filter
- Two queries for a WP_User_Query search work perfectly apart, but not together
- Setting default category base on theme activation
- Trying to get a PHP variable defined in a custom post into a javascript file. Null value. Using wp_localize_script
- Recent Posts Not Showing Only On A Specific Category Page [closed]
- Hide subcategories (widget)
- Alert Bar section within WP loop is displaying even though there are no posts
- Let Users Choose Post Categories
- Archive post by meta value + 24hours
- Different post styles depending on category
- Display category name only once inside loop
- Query if audio attachment AND/OR custom field
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- How to show only subcategories in parent category not parent category?
- Genesis framework comments broken?
- $wpdb->insert() does not Insert record in a table
- register_taxonomy() take much queries
- Databases – Submitting data from inputs to database [closed]
- WordPress SQL injection
- how to show only specific category for a template
- Which is the correct way to conditionally enqueue a CSS file?
- Dilemma of Populating all the categories in a drop down list
- Odd / Even posts add class minus first post
- Display most popular posts of category
- Creating sub-categories via php
- Define specific category name in PHP
- Edit the_category (); for a hierarchical display
- JSON REST API WordPress only showing first 10 categories
- Category title output before opening title tag
- unable to use ‘new WP_Query’ in AJAX call
- get taxonomy thumbnail and use it as a variable in code
- Include Parent Term in wp_list_categories
- Is it best to avoid using $wpdb for security issues?
- Parse error: syntax error, unexpected ‘}’ on get_the_author_meta [closed]
- How to array only one key from another array
- I’m trying to create an array with a foreach loop, but the array only stores the last item [closed]
- How to list commenters and days since last commented
- How to add div blocks after certain set of post
- Get all categories post is not in
- How to overwrite orderby with add_query_var
- Can’t update multiple rows with $wpdb query
- Get latest post from all categories except one
- Displaying posts based on category
- How do I remove a category from a wordpress loop>
- Get categories names as an array to use it in theme settings
- working with term_relationships table
- Overriding default calendar to show posts from a category