Have you looked up the WP Codex on WP_Query for categories?
They provide an example here. Also your category variable should probably only have one $
. The way you’ve written your custom query also looks wrong, are you using WP_Query?
$query = new WP_Query( array( 'category__and' => array( 2, 6 ) ) );
Related Posts:
- is_category() in pre_get_posts strange error
- Rearranging posts based on categories
- Custom Query to search through categories
- How to query all posts of a specific category, and any other category combination
- is_category in pre_get_posts results in php notices
- Query the Loop without breaking it
- How to Check if a Child Category is Being Queried
- How Do I Merge Categories With phpMyAdmin
- Category archive page – loop through posts of certain tag (with pagination) – pre_get_posts
- If newest post of category is newest post in general, skip first post of category
- Disallow categories from this MySQL query
- Include posts from feature category in pre_get_posts
- How to display posts under a specific subcategory of a given category
- get_the_category and echo out link to child-most/deepest category
- query in category.php repeats itself
- Display posts separated by Category in Author’s page
- Category param redirect to post type archive
- How to get related tags based on a category?
- Show popular post by category code
- How to get latest posts from each category in regular order
- category pagination got broken suddenly
- How to query categories with Advanced Custom Fields?
- Where and when does WordPress invoke routes
- And/Or Category Query
- Exclude category from query
- Overriding default calendar to show posts from a category
- function query_posts disabling current_page_menu class
- How Do I Delete WordPress Posts Older Than 400 Days, From A WordPress Category
- Using in ‘category_name’ in ‘$query->set();’?
- custom query for both category and pages using global $wpdb;
- Get categories of queried posts
- How to display posts from specific category using get_option function?
- SQL query to get posts from multiple categories but not in a category
- Conditional category query breaking?
- How to filter post from categories only if the posts appears in one of them, not the other?
- Category name for all posts getting assigned to a single random post
- Show Posts via cat+cat in URL that are in both Categories doesn’t work
- List of post categories only associated to another custom taxonomy
- how tho change number of posts in loop from specific categories
- Get category from slug list
- Issue with WordPress category search
- Querying posts from two different categories while looping inside another loop
- how to get postmeta info based on multiple categories?
- Too many categories drastically slow down my website
- How to get posts from many categories using WP_Query
- Is it possible to query the result of a query?
- show posts found in multiple categories via category_name query string?
- Match two taxonomies to display a specific content
- Category slug in in loop always the same?
- display certain category on custom template page
- Detecting top parent category fails on home page
- How to use Greek characters/letters in a query?
- Displaying posts by year
- wordpress category.php query for featured news item, broken pagination and repeating posts
- How to show posts of a specific category
- Can I set a default featured image for a category?
- What’s the URL for a category archive?
- how to use a different domain/subdomain for authors/catagories on single site?
- Category count inside the link
- Is there a way to have duplicate category slugs?
- Multiple level category drop-down
- how to show posts of category random by session
- Remove “Parent” Selection When Adding/Editing Categories?
- Show post only if match all categories
- How to get product count with respect to categories in WooComerce
- Password protect a specific category page/post
- Querying Term Posts in Loop
- Additional featured post on first page
- Displaying a full post instead of a slug per category?
- How do I toggle pagination on/off in search results and category listings via a link?
- How to show WordPress parent and child category using a different template?
- How can I get categories IDs if multiple categories requested via URI?
- List categories with custom code
- Categories widget show empty?
- Trying to get variables in hacked category dropdown
- Change of category structure will cause two kinds of URLs for one post
- Portfolio Filter Buttons Wont Work
- Change slug of Standard wp Post category
- Get posts of a custom post type from category from taxonomy?
- Hide a category of posts from main blog, and only show in category view
- ACF no print data [closed]
- Change categories count to include media attachments
- Archive filtering
- How can I check which archive has referred the single? [closed]
- Is the part “category” fixed to an URL to an archive or post?
- How can I use AJAX with check-box categories?
- wp_delete_term or wp_delete_category?
- List Categories By Specified First Character
- the category city made as a subdomain
- Displaying Single Product Page Parent and Child Category
- wp_get_post_categories not work currently on loop.php
- Get category base permalink
- WooCommerce showing active product categories on single product page
- how to exclude specific category types (uncategorized) from blog page?
- Style a category page the same way as the homepage?
- Display Taxonomies in loop with template args
- How to assign image on specified category and not show the image on other categories
- Display only the latest post
- How to add location as category?
- Replace category titles inside RSS feed