You can make query like this
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
$args = array(
'post_type' => 'post', //Specyfying post type
'cat'=> 1, //Selecting post category by ID to show
'posts_per_page' => 10, //No. of posts to show
'paged' => $paged //For pagination
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
//To show Title of post
the_title();
//To show ID of post
$id = get_the_ID();
echo $id;
/***** Featured Media ******/
the_post_thumbnail(
array(120, 90), //Width and height of featured image
array(
'class' => 'thumbnail', //class to apply css properties
'alt' => 'post thumbnail', //Alternate text if there is no image to show
'title' => 'my custom title' //Title to specify
)
);
/******* Featured Media Ends ********/
endwhile;
Related Posts:
- Rest Api How to get results of child categories with one api call
- Slow WP_query due to nested wp_query. Need Suggestions
- WP_Query not ordering correctly
- WP Query Relations / Compare
- WP_Query leaking absurd amounts of memory
- Fatal error: Class ‘ms\WP_Query’ not found on plugin initialization [closed]
- Register custom query args parameter for WP_Query()
- Check for featured image in WP_Query
- How to check WordPress website username and password is correct
- How to get data from WordPress $wpdb into React Gutenberg Blocks Frontend?
- get_posts / WP_Query Memory size of 134217728 bytes exhausted
- How to ensure “the_content” filter runs only for the main displayed content?
- add_filter and remove_filter added before and after wp_query
- How to: Rest endpoint returning empty object
- Custom endpoint that returns an xml
- WP rest api v2 posts filter by ‘search’ & ‘category_name’ not working
- What method to use to call a REST API?
- Cannot search post by taxonomy
- WP_Query with tax_query, order by most ‘matches’
- How to print raw query from WP_Query class just like in CodeIgniter
- WP_Query returns no results
- WP REST API V2 – Add user data to response
- manage_posts_custom_column, showing serial number using increment in loop
- Proper way to run wp_query from inside a plugin
- using new WP_Query in save_post function alters $post
- How to get results of subcategories also?(WP Rest Api v2)
- ORDER BY wp_post custom column name in wp_query
- How can I create ‘future’ and ‘past’ parameter for restAPI by filtering the CPT custom date field by greater than / less than current datetime?
- Amending REST API function without deactivate/activate plugin every time changes is made
- Create a new post using rest api and save featured image using an external image url
- Elementor custom Query with ACF fields to show matching woocommerce products custom fields
- WP_Query filters
- How to get Metabox custom field to show checked if value is updated using post meta query?
- Serve text/html from wp-json API via WPEngine, headers not being set properly
- Get attachments from a post
- Secure REST with nonce works only when not logged
- How to do POST request with WP REST API v2 to custom table?
- Search: how to extend the existing search to include a custom table
- pre_get_post alter current post id
- how to invoke wordpress API from other existing PHP system
- How I can use order by of the custom post title?
- rest_no_route on custom API endpoint wordpress
- How to query children by post name/slug
- Custom Rest Endpoint: Post/Put/Patch not working
- 400 Bad Request, in wordpress theme development, wp_ajax
- Why in this archive page that call query_posts() function show only the last 10 posts?
- Can’t retrieve body params from PUT endpoint using formdata
- Do I need to create an endpoint?
- How to use apiFetch to get author information in Gutenberg properly?
- how to load the comment template from a plugin
- Mock a dependency of a WP_REST_Controller class
- Auto-complete or auto-suggest from stored data in database
- Pagination not working with custom wp_query
- Get Posts by IDs (optionally)
- how to get the top 10 popular blogs
- WP_Query order posts by category
- Allow REST API Endpoint to specific user and hide from public
- Is it possible to use the MySQL’s ORDER BY FIELD() clause as part of the pre_get_posts hook?
- How to do admin ajax request in a plugin for rest api
- Query String Filtering API
- Custom plugin & calling REST api of wordpress instance the plugins is running on
- Get Custom taxonomy parent with wordpress REST API
- register_meta not showing custom post type metabox data in rest api
- why is apiFetch throwing Unhandled Promise Rejection: TypeError: Object is not a function
- Securing custom rest API endpoints with public access from PWA
- How to check category name available or not
- Home page is not loading, where in other pages are displaying on the site
- 403 error rest_’cookie_invalid_nonce’ on API Request
- Adding Amchart Interface to WordPress API
- WC REST API Error Handling
- User meta query using Wildcard
- Initializing rest endpoint issue
- WP Query date_query with several date range
- React in plugins: REST endpoints vs. regular functions
- admin-ajax.php returns “No Script Kiddies!” sometimes
- Making Woocommerce optimized for more than 500k products
- Post Pagination does not working on WP-Query
- pull data from wordpress database
- How can I query 3 posts from diferente categories (one of each category)
- WP API users per page
- Custom MySQL query to pull out Advanced Custom Fields?
- post_results filter confused by pagination in sidebar and main section
- How can I add recent posts to menu like mashable
- Best place to keep files that are called by cron jobs?
- Get custom wp_query search results to appear on search.php
- Is it safe to use PUT and DELETE requests
- WP-Snap too slow (caused by WP_Query?)
- loop and in admin header problem
- How do I query posts and have their related taxonomies returned in the results?
- Get next page in get_posts
- $_GET vs get_query_var()
- How to update WordPress Plugins in your own maintance application?
- Extend Plugin that creates an endpoint for GET request to also accepts POST requests
- Return custom product in ajax call loop
- How can create a custom plugin to call my webapi after any registration or membership plugin functionality
- Rest Api WordPress
- Does WP REST API cache internally executed (rest_do_request) requests?
- REST API error in block editor for custom templates
- Execute callback after REST API request completes + Response is sent
- Accessing Correct Database to Create REST API Endpoint