$args = array(
'post_type' => 'post', //Specifying the type of posts
'cat'=> 1, //Selecting post category by ID to show
'posts_per_page' => 4, //No. of posts to show
'paged' => $paged //For pagination
);
//You dont need to use query_posts( $args ); since you are using wp_query
$query = new WP_Query( $args );
Use while loop like this
while ( $query->have_posts() ) : $query->the_post();
Instead of this
while ( have_posts() ) : the_post();
In case if you don’t know where to find post ID, Read this article to know about post ID
Related Posts:
- Retrieving 3 latest post from each of 5 different custom post types
- Query for posts in 2 taxonomies
- Quickest way to get last or oldest post date – WP Query
- Separate Posts and Custom Post Type in Custom Taxonomy archive template
- pagination not working for category.php (custom post types in categories)
- Pagination not working on custom query on a page
- postsperpage value not being applied
- Custom Post Type Query W/Category Dropdown
- display news with pictures 3 small and one large (loop)
- How to exclude certain portfolios from a loop
- show custom post’s post in two different divs [duplicate]
- Get the ID of the latest post
- How do you get the count of posts in an archive page?
- WP_Query vs get_posts
- Custom post type archive 404’s with paginate_links
- Display Custom Post Type Fields
- How to get the parent’s taxonomy?
- Using new WP_Query in shortcode in a custom field causes the main post content to not display
- Should unaltered default loop/query return a list of custom posts belonging to a custom taxonomy?
- How to get only one category of custom post type?
- exclude custom post type by meta key in wp_query
- How do I Use Nested Loops of Custom Post Types for MultiSite Blogs using WP_Query()
- Impossible to get Attachments Outside WordPress?
- How to dynamically build a multiple taxonomy query loop within a post type’s single loop?
- Unable to get post content from custom post type loop
- Help Structuring Query for Archive Pages
- Custom query shows custom post types in trash
- Multiple post type queries (with specific arguments for each)
- Remove duplicated values from a loop
- Custom Post Type Loop within Shortcode
- How to connect two custom post types with nested loops
- Query custom post type in the loop
- Display CPT posts based on specific taxonomy
- Query/list all terms and their custom post count
- Show one item per category of a custom post type
- Show a Category X’s custom post type on Category X archive page?
- Query Multiple Custom Posts by Custom Fields
- WP Query with categories only shows one post and ignores the category
- Polylang non-default language ignores tags in WP_Query
- Problem: wp_query outputs all images on site
- Different Ways to Query Custom Post Types?
- Listing all term items alphabetically / sorting loop
- How to display Related Posts based on number of taxonomy terms matched
- Wrapping x posts in html without leaving empty html
- Sort posts in loop by the WooCommerce Membership of the author
- How to make WP_Query not to show irrelevant posts?
- Loop for custom post types filtered by a taxonomy
- Loop increase number
- Using wp_query to modify the loop in index.php for a CPT
- Custom WP_Query doesn’t display all posts
- Query & the_content() is showing in the header
- get_posts output always same post
- find custom post type post by searching its custom field with my string
- FacetWP paging custom wp_query
- display posts of custom post type with custom taxonomy
- Can’t change posts per page in WordPress Post Type Query
- Group by custom field value (start and end times)
- Query all post types but limit to parents
- Get posts by category name
- foreach loop inside the loop creating duplicates in output
- How to properly use Categories with Custom Post Types
- 4 posts per page from single category
- How to fetch posts that are stored in the different table than (default) wp_posts?
- Cant’ Display Custom Post Type Title Base on Tax Terms
- How do I list a custom field and custom taxonomies for each result in a loop?
- Multiple custom post type queries causing wrong post types to be grabbed in taxonomy + single templates?
- Query for specific taxonomy that executes a particular loop depending on volume of posts?
- Custom Post Types Not Showing Up In query_posts Result
- Find Posts based on Child Post value
- Custom Post Type ‘Event’: Chronological list of recurring events from meta_values in array
- Page that lists publications by classifying them by taxonomy
- Exclude a specific post in a Custom Post Type
- Pin posts to top of custom loop
- Filtering posts based on three taxonomies
- Error in the page of a CPT file in WordPress
- Wrapping an unknown amount of posts inside separate HTML Containers during WP_Query loop
- minimize wp_query call to database
- sorting in wp query based on custom field value
- Query posts based on user preferences
- Query the title of the page to show posts with matching category in the loop
- WordPress query in which condition uses custom field
- WordPress loop add heading before first of type
- Only show current category post
- Error in WP Query. If variable is empty it is displaying previous post value
- Main site single-property.php design, as homepage of a multisite
- Ordering Posts by parent category, name ascending
- WordPress custom post type
- Post data in separate divs with incrementing class using WP_Query
- Query posts by a type and another type only if post is in specific category
- Custom Query With Multiple Meta Key Value
- Query Posts From Multiple Post Types
- shortcode for recent custom type post
- next_posts_link returns same content of 1st page
- Custom loop won’t work, can’t find problem
- Render a loop in Timber (twig for WordPress)
- Display ACF object field data using Elementor Custom Query
- Assign a tag to custom post type using a query
- How to insert a post from a different post type after every nth post
- Complex Custom Loop with Includes
- How do I exclude the current post from the upcoming post query