You have to know the ID/s of the category/categories you wish to show.
Then add 'category' => 'X' in the array. X is the ID of your category.
Example: $args = array( 'numberposts' => '5', 'category' => '3' );
or if you wish more then one category: $args = array( 'numberposts' => '5', 'category' => '3,6,7' );
Related Posts:
- How to get posts published between a date and today?
- Display all posts from specific categories on a page
- How to exclude latest x posts from a paginated query?
- Display content from a specific category
- Can’t show comments count per post outside loop
- How to Display Post View Count
- How would I get 1 latest post from a query for 5 posts?
- Inserting custom data to the_post() during loop
- How To Get Posts With A Specific Word
- Why WP_Query(‘showposts=5’) shows only 1 post?
- Display all posts that were published before full post on single.php
- 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
- How to order posts in an arbitrary order?
- Display Posts on Custom Page
- Wrong post title displayed from loop
- Get the amount of posts on a current page
- How to get posts published on the latest date?
- How to only publish posts with image in it
- WP_Query: Show 10 posts in date order, first three random
- Display 3 posts with different HTML markup using a loop
- How to show post views shortcode data for each post on Posts List Page?
- Use special template for the first post in the loop
- Modify WordPress loop after it has been run
- show latest authors blog post
- Why I obtain this WP_Query strange behavior trying to select posts having a specific tag?
- Adding a category at even positions on main loop with modified pagination
- How to inject a post within a loop
- Why does ‘get_the_ID’ work outside of the loop?
- Keep featured content post in homepage with original order
- How set featured posts using checkbox in post edit screen?
- WP_Query: Why is sticky post not first item in loop?
- How do I reorder (pop and push) items from WP_Query?
- how to display full post with pagination on home page
- This AJAX Code Doesn’t Work – Looking for elegant solution
- How to use alternate post layout at key points in post loop?
- Order post by year DESC and month ASC
- Showing random content / pictures from earlier posts in a sticky post?
- Function to show random posts from a category
- Double count view in archive.php
- Group posts by year in loop
- Different style for most recent article
- Differentiate between posts and pages in search results
- Loop through all product posts?
- Create dropdown list post
- get_next_post() and get_previous_post() return wrong posts
- Display post category in foreach loop with category link
- Displaying Latest Posts on a Page
- How to add tags (custom taxonomy) to post class css?
- Listing Specific Categories from Current Post with Depth
- Only display sticky post or latest post in custom loop
- get_the_category listing in hierarchial order
- Exclude current custom post on single post
- Nested WP_Query breaking loop
- do more action after I publish a post
- Retrieve only posts from a specific user in wp-admin/edit.php
- Grid post page on WordPress with Bootstrap, the_excerpt(); Problem
- Custom taxonomy archive page problem
- Loop don’t work within single.php page
- Query for first 3 posts to change the look and feel
- Getting blog pagination to work on page set as front page
- Make loop inside slider divisible [closed]
- How to add automatically bootstrap 4 order-lg-1 and order-lg-2 classes for columns in foreach loop based on the count?
- On what hook can I get the queried object’s final state?
- How to display post list in a table layout (multiple queries in single loop)
- Not all posts showing in query
- WordPress query portfolio posts
- Optimize CPT-function with a loop
- The loop starting at a certain ID
- WP_Query articles order by offset in collumns
- Limiting the amount of posts retrieved by the loop
- Getting posts from some categories plus some individual posts
- Error while excluding a post from another loop (using its ID)
- How to merge the content of posts that have the same title?
- Diffrent layout for posts [duplicate]
- show loop id post , only first id can read
- Show post excerpt
- Querying posts from current category, using a variable as array argument
- Wp_query loop is not working as it should
- Maximum number of posts per page before affecting performance?
- Display post order ranking within wordpress loop
- Problem with wp_insert_post()
- How to control Post view count incresing in sidebar widget posts too?
- Need help writing loop to display posts by categories in separate divs
- Query post category & remove any post id
- Multiple Post Repeat for Related Post Loop by Category
- Where should get_post_meta() go to get $post->ID get_post_meta() is empty and $post->ID & get_the_id() are working
- Loop through posts by each term and exclude duplicate posts assigned to several terms
- How to limit the number of results for all query_posts on mysite
- wp_query select if have comments
- How to limit post query to only return a total count of items with certain post statuses?
- Only show posts with image and the correct ammount of posts in loop
- Related posts by searching post tags of single post as terms
- Not displaying any articles on a custom made file
- Redirecting posts in WordPress to a specific page
- Wrap every 2 posts
- What template file is used by default for posts?
- How to show related posts by detecting the current category?
- Display posts on a custom page from only a specific category?