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
- Print Current Post Index number within Loop
- the_author() returns empty string
- rewind_posts() – what actually the use of it, and where using is required or preferred?
- How to show list of posts by author and category?
- How to display posts by current user/author in a custom page template?
- post_name empty after wp_insert_post
- WordPress Number of Posts Not Changing With posts_per_page
- Find most recent authors
- Query only Posts from Both of Two Category?
- Insert custom div between posts
- Different amount of posts on homepage than paged pages
- Displaying the number of posts in a custom loop (without including the number of posts of a loop below)?
- The correct way to call posts with ajax
- Converting multiple loops into one single loop with pagination
- Exclude posts with empty post_content in wp_query
- Alternating post layout
- Check to see if specific loop has less than certain amount of posts
- Multiple loops are not reset
- is there a way to show the the post title after the image?
- Exclude category from
- Post Loop Missing Most Recent Post
- How to : pagination in 3 different custom loops on the same page
- Display an author’s posts on his own author page
- Start WP Pagination From Number 1 in URL
- Use two different post_per_page limits with infinite scroll
- How to get posts from a current post’s month?
- While loop articles – if statement order
- Change all author links in Blog roll
- Page and post loop same template
- WordPress Query Posts From Category Post on Static Page
- Post Filtering by GET URL parameters
- Loop through posts? Want to remove extra newlines in actual post HTML/content on backend
- Get post by tag
- How to display posts on custom page without declaring a posts page in reading settings?
- Cannot implement byline into posts container in single.php
- How to check if there are posts with the same tag
- Custom WP_Query not working correctly
- Echo the number of posts being displayed
- Exclude a category of posts in author template
- WP_Query of Category Not Showing First Post
- How come this loop is not working? [closed]
- Using the loop to set locations for all posts on a single google map
- Change content off every sixth element
- Want to change the post every three days with in specific category
- Separate top level categories on archive-product.php by meta
- While loop in functions.php outputting the_title() of each post on frontpage
- Shortcode for Comments and Comment Boxes in Post Loop
- Show posts from two specific category in WP_Query
- Permalink Short code showing unnecessary link text inside the loop
- How to create loop of posts except post ID defined via ACF field
- Multisite how to display merged posts from two sites and sort by latest date?
- How to display particular categorie’s post which associated to specific user?
- Double loop output
- post->ID displays the same ID number for every post
- How to correctly escape data
- Posts are not showing up on next page.
- Sort Events by Venue Title – Sort Post set by related post ids
- Post are not showing up
- Get posts by category or author
- How to make post button to a random post
- How to pass multiple checkbox values to wordpress query?
- Make assigning post to a specific category equivalent to assigning it to all categories
- How to get all post titles starting with numbers and symbols?
- what template-part to call, to have my post in the center of the page?
- How to show only the date, the title and a little “summary” of my WordPress post in my custom theme?
- posts_per_page – Repeats only first posts ‘post__in’ array
- query_posts different amount of posts per page [duplicate]
- Do I need to create a multisite for querying posts from multiple WordPress sites?
- View post with specific category id and name which I selected in the backend (drop-down option)
- Dynamic archive of posts by date
- WordPress Ajax load doesn’t work