I’d Advise adding the arg of the category in an array. And don’t use query_posts
.
Also showposts
is deprecated use posts_per_page
instead.
$args = array (
'cat' => array(2,6,9,13),
'posts_per_page' => -1, //showposts is deprecated
'orderby' => 'date' //You can specify more filters to get the data
);
$cat_posts = new WP_query($args);
if ($cat_posts->have_posts()) : while ($cat_posts->have_posts()) : $cat_posts->the_post();
get_template_part( 'content', 'page' );
endwhile; endif;
Related Posts:
- How to get posts published between a date and today?
- How to show related posts by category
- How to show list of posts by author and category?
- How to exclude latest x posts from a paginated query?
- Display content from a specific category
- Query only Posts from Both of Two Category?
- Can’t show comments count per post outside loop
- How to Display Post View Count
- Featured Posts for Category Pages
- Divide Loop Into Days & Categories
- How would I get 1 latest post from a query for 5 posts?
- How to filter posts that belong to a specific category only if that is the only category
- Inserting custom data to the_post() during loop
- Display post category in foreach loop with category link
- How To Get Posts With A Specific Word
- How to display posts on a static page? (like search loop)
- Child_of not displaying all children posts.. via get_posts
- Why WP_Query(‘showposts=5’) shows only 1 post?
- Display all posts that were published before full post on single.php
- Category Foreach keeps looping?
- Exclude category from
- Blog post per page setting conflicting with custom WP_Query?
- How to exclude latest x posts from a paginated query?
- Two loops, one AJAX loop, exclude posts in first loop from second loop, loops are in different files
- Pulling in post category and children within category
- how to show single post in a custom template
- Listing Specific Categories from Current Post with Depth
- How to make multiple sections in home pulling posts category wise?
- How to make the first post in the loop be styled like a “new / featured” post?
- How to order posts in an arbitrary order?
- How do I stop the loop from repeating in my category template?
- get_the_category listing in hierarchial order
- Display Posts on Custom Page
- Wrong post title displayed from loop
- why does wordpress ignore the post args?
- Showing categories and subcategories with posts
- Get the amount of posts on a current page
- How to get posts published on the latest date?
- Problem with different query loops (and “main loop”) on category template page!
- How to only publish posts with image in it
- WP_Query: Show 10 posts in date order, first three random
- All categories displays the same posts
- Display specific posts on home page
- WP_Query of Category Not Showing First Post
- WordPress displays post on subcategory only
- How to get posts ordered by using their categories?
- Get post category as a separate string and url
- Display 3 posts with different HTML markup using a loop
- Getting posts from some categories plus some individual posts
- posts going to 2 pages/categories only show up in 1
- Get current taxonomy and display query accordingly
- Only the most recent post is showing on my category page (working on localhost, not live site)
- Current post categories and subcatecories outside of the loop
- How to show post views shortcode data for each post on Posts List Page?
- How to distinguish pages created by woocommerce?
- How to display particular categorie’s post which associated to specific user?
- How to show category image if no featured image is set?
- Display new posts categories in separated divs
- Querying posts from current category, using a variable as array argument
- Use special template for the first post in the loop
- List Authors For Current Category
- Need help writing loop to display posts by categories in separate divs
- Modify WordPress loop after it has been run
- Query post category & remove any post id
- show latest authors blog post
- Post gallery as carousel
- Multiple Post Repeat for Related Post Loop by Category
- Why I obtain this WP_Query strange behavior trying to select posts having a specific tag?
- How to pass multiple checkbox values to wordpress query?
- Show post if in category
- Adding a category at even positions on main loop with modified pagination
- Displaying categories items among posts
- Make assigning post to a specific category equivalent to assigning it to all categories
- How to inject a post within a loop
- single.php fires more than once after clicking on any post to view with different post id each time
- Show all posts in category
- Change from all posts to specific categories post on main page?
- View post with specific category id and name which I selected in the backend (drop-down option)
- Sort Posts Alphabetically Based on Specific Category (Divi)
- Display only posts from a specific parent category
- Multiple loops in same page, without duplicate content
- Adding specific post category between posts in loop
- Properly display posts on homepage
- Hide a specific post from a page template
- Posts – display all posts except a post by an ID
- older blog posts not showing in new theme
- Pagination on category.php and tag.php not working
- displaying the categories post
- Separate top level categories on archive-product.php by meta
- While loop in functions.php outputting the_title() of each post on frontpage
- Is there a way to save different data when USER interacts with the same POST?
- show only one category and filter by tag
- How can I exclude only a specific sub category post from category display?
- How to correctly escape data
- Posts are not showing up on next page.
- Get posts by category or author
- How to make post button to a random post
- How to show only the date, the title and a little “summary” of my WordPress post in my custom theme?
- wordpress show category link instead of post link [closed]
- CSS – Change height of Storefront / WooCommerce product categories, but not products