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
- How to get parent and child sub category (Taxonomy) order to display
- How to get category and archive title?
- How can I create a category landing page followed by pages of posts?
- How to split the categories of subcategories with thumbnails
- Add custom category name as data-filter to switch between these categories
- Get all the blog’s categories and the related URLs?
- Update taxonomy value of post type in query
- Is it possible to add short code and html tag in Category Description?
- How do I specify more than one category?
- Set post categories to include parents when setting child category
- Making a tourism information website [closed]
- Adding Categories Through Function
- WordPress search only showing a few posts
- How to recreate a copy of a product category in WooCommerce? [closed]
- Multiple category archive page
- List subcategories of active parent category (WooCommerce)
- How to display post type and category links in foreach WordPress code
- Updating category template to change how subcategories display
- How can I setup a relationship using categories in WordPress?
- Add multiple classes. Different style for each category tag
- Limit categories and it’s subcategories for specific group of users
- Admin: Navigation Menus do not show empty categories/taxonomies in the list’s search tab
- getting post data in functions.php
- Category specific order
- Remove the number of posts displayed in wp_list_categories()
- related articles using shortcodes
- “Virtual category page” based on a custom field filter
- Rebuilding a Site: How to Show Several Category Posts in Woo Framework Theme?
- Different header for each category
- 3.1 post formats and specific categories/custom taxonomies
- sidebar troubles, taxonomy trouble
- Code for Category, Tags, Archive URLs
- Duplicate new categories across multisite network
- Display all subcategories from parent category
- How to create Child Category page from scratch at wordpress?
- How to insert category to post via php?
- Show Subcategory Name Instead of Parent Category
- Get category id of next / prev post inside the_post_navigation
- Query posts from newest category
- Limit Category/Tag Dropdown To blog_id in Multisite Install With Global Categories/Tags
- Code to display category-specific single.php is overriding normal single.php, too
- Media Library filter returns undefined function get_current_screen
- Custom built theme won’t filter categories
- get IDs from links categories
- Display all subcategories for a product category in woocommerce