$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]
- How to properly use Categories with Custom Post Types
- How to retrive Custom Post Type Meta Fields in Custom WP_Query
- 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
- Custom Post type showing up in loop, regular posts are not showing up
- Loop for custom-post-type comparing taxonomy terms for “related” posts?
- How do I list a custom field and custom taxonomies for each result in a loop?
- Magazine style frontpage with multiple categories/loops and no duplicate posts
- Multiple custom post type queries causing wrong post types to be grabbed in taxonomy + single templates?
- Custom post type pagination error
- Query for specific taxonomy that executes a particular loop depending on volume of posts?
- Custom Post Types Not Showing Up In query_posts Result
- What is the most efficient way to execute recursive complex queries?
- Find Posts based on Child Post value
- Custom Post Type ‘Event’: Chronological list of recurring events from meta_values in array
- Sorting the Loop by Taxonomy Value
- Custom Query: Multiple CPTs and a taxonomy filter
- WP query_posts group by meta field related
- date_query empty results with custom post type
- Page that lists publications by classifying them by taxonomy
- Custom wp-query display post only today
- posts_per_page in custom WP_Query does not override “Reading” settings?
- Exclude a specific post in a Custom Post Type
- Pin posts to top of custom loop
- custom post type and a “sticky” position taxonomy
- Filtering posts based on three taxonomies
- Pagination Not Working When Used With WP_Query() `offset` Property
- Order posts alphabetically with numbers but some of the posts has numbers in the title
- Modify default Related Posts Code to Custom Post Type
- Use WP_query to match post types based on custom field values
- SEARCH QUERIES – REVERSE OUTPUT
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- Error in the page of a CPT file in WordPress
- post_type incorrect for custom post type
- Staggering featured post using ‘sticky’
- Query a custom taxonomy in a function to create an csv file
- Wrapping an unknown amount of posts inside separate HTML Containers during WP_Query loop
- minimize wp_query call to database
- subtracting the current post form then whole loop, which is generating all CPT titles
- Mix Facebook and Twitter feed into custom posts
- sorting in wp query based on custom field value
- Can I show some specific post rather than latest post?
- Query posts based on user preferences
- Custom post Query and WordPress Post Query Clash
- Query the title of the page to show posts with matching category in the loop
- Why get_posts() returns empty array while I am trying to get posts from some specific taxonomies and work properly with others?
- Get post from Category by Priority
- WordPress query in which condition uses custom field
- WordPress loop add heading before first of type
- How can you use a page for a custom post type?
- Only show current category post
- How to make a shortcode for my WP_Query Loop? [duplicate]
- Error in WP Query. If variable is empty it is displaying previous post value
- Strange behavior on WP_query
- get_post_meta for Custom Post Type ( CPT )
- Main site single-property.php design, as homepage of a multisite
- Create a hierarchical loop at predefined markup requirements
- Imported Content Doesnt Show Up On Frontend
- How To Loop Through list with Custom Post Types
- Ordering Posts by parent category, name ascending
- This wp_query will not return any posts and only seems to work with post_status inherit?
- Is it possible to add query parameters on the archive page?
- Custom Post Type + Category archive
- WordPress custom post type
- Loop with Custom Post Type and Taxonomies
- Post data in separate divs with incrementing class using WP_Query
- How to create content automatically when a post is published?
- Query posts by a type and another type only if post is in specific category
- Custom Query With Multiple Meta Key Value
- How can I pull information from my loop and divide them seperately?
- Custom post type blog pagination conflict
- Query Posts From Multiple Post Types
- Fallback if statement based on the number filtered from it
- shortcode for recent custom type post
- next_posts_link returns same content of 1st page
- Custom loop won’t work, can’t find problem
- Custom post-type’s pagination not working in category.php
- send user to first page of results when reposting to page?
- Query Custom Post Type by Tag
- Fourth page of custom post type archive page does not exist
- Catergory args causing loop not to show
- display custom post type from register taxonomy
- Custom post type and have_posts() return empty result
- Render a loop in Timber (twig for WordPress)
- Quering array of post types & pagination. Articles are repeating sometimes on different pages
- Display ACF object field data using Elementor Custom Query
- How can I show posts with the same tag?
- Assign a tag to custom post type using a query