Below is the code for getting posts from multiple categories using WP_Query
Just correct the cat value, it is used without an array. Check out Codex: WP_Query – Category Parameters link for more information.
WP_Query( array(
'posts_per_page' => 7,
'cat' => '5,3,7',
) );
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
- Query from multiple category (and)
- 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
- 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
- Can I set a default featured image for a category?
- What’s the URL for a category archive?
- Weird behaviour when adding terms/term_taxonomies programmatically
- Multiple level category drop-down
- Show post only if match all categories
- Password protect a specific category page/post
- Querying Term Posts in Loop
- Different excerpt styles per category, but chronological
- Filter Home Page Posts in Buddypress [closed]
- Additional featured post on first page
- Color different for the current category
- How do I toggle pagination on/off in search results and category listings via a link?
- Category shows only top level child categories
- List categories with custom code
- Add a custom category page in WordPress.org
- Remove the parent name from permalink
- Make parent category an optgroup
- Count category views – Is it possible?
- wp_dropdown_categories not showing option as selected
- How to check if a post belongs to a category that has only 1 posts?
- How do I use just one category’ posts on my home page?
- How can I display tags as categories?
- On the Blogpost I have categories showing, is there a way to exclude a catgegory like ‘Media’?
- Set category page title in custom theme [closed]
- Posts from a category on homepage with category archieves page default css
- How to use wp_list_categories with plugin category?
- Theme modification for custom category menus
- Custom css per category and per single post belong in each category
- Limit Loop to One Category
- wordpress taxonomy query posts
- Display all subcategories from parent category
- Custom Loop with certain number of one category
- How to show WooCommerce Categories on ‘shop’ page instead of products?
- How to list all subcategories from all categories but not from a certain category
- Automatically create tags and merge with categories
- How to list all categories a post is in, but exclude current post´s category on single post page
- How to grab posts from the most recently created category
- Query post category & remove any post id
- Modify / Rewrite single template url structure
- category filter doesn’t work
- how to edit wp category widget
- Only show sub-category
- Link to page in category
- get_category_children/ the new get_term_children not work