try this
<?php
$new=new WP_Query(array('posts_per_page'=> 1,'order_by'=>'DESC'));
$max_id;
if($new->have_posts()){
while($new->have_posts())
{
$new->the_post();
$max_id=the_id();
}
}
echo $max_id;
Related Posts:
- why ignore_sticky_posts in sticky post query
- get_query_var( ‘paged’ ) not working outside of homepage
- get custom post type by tag
- Does tax_query really beats meta_query in all situations?
- WP_Query by post ID doesn’t work if post is in custom post_status
- Using WP_Query To Get Posts Randomly From today
- How to know which one is the main query?
- WP_Query can’t exclude more than 1 author?
- Finding all results from database within 500 miles of the given latitude and longitude [closed]
- How to order posts by custom WP role?
- posts2posts query using connected_items array issue [closed]
- WP Query and order by particular specified IDs
- Get the post permalink within the loop but without additional DB query
- Display revision if post status is pending
- Meta query field order together with post_date order causes posts without the meta field to be unordered
- How To Remove/hide some specific categories from two different categories widget from sidebar
- WP Query search for attachments and their exact title
- How to add another parameters to WP_Query?
- Display link to taxonomy archive only if it has posts with certain custom field values
- Excluding Sticky Posts from The Loop and from WP_Query() in WordPress?
- How to display posts month by month?
- Display posts with date wordpress default
- Query different number of posts with different formats in one go
- Extending woocommerce admin product search
- Pagination is broken and I need help fixing it
- Query total number of posts
- Category attribute not working in custom shortcode
- How to display a posts 1 year ago with custom WP_Query loop?
- Check on which page specific result exist
- WC displaying products from category
- Loop returning only 1 result
- Fetch posts that match term slug first two letters (wp query)
- pagination with numbers for WP_User_Query
- How can I use $wp_query->tax_query as tax_query parameter for a new WP_Query instatiation?
- How does one perform a sub query with different post types
- Query with search and subscribers only output
- Stuck in the query loop
- Query Page Content From Theme Options?
- Filter wordpress post categories with jquery/ajax and pagination?
- Taxonomy order exception for specific term
- next_post_link / previous_post_link not working with WP_Query
- How to Create a Random List of Child Pages
- Query_posts works when appending via AJAX call wp_query doesn’t?
- Is there a way to make this kind of loop shorter and nicer?
- How to make posts unqueryable/unpublish posts where ACF relationship field is an unpublished post? [closed]
- WP Query ordering on a meta field for posts with a date in the future not ordering by datetime
- Merge 2 custom post type posts and taxonomy terms and sort ascending
- Pagination on template page for custom query redirecting to index.php
- Get all posts with empty meta_value
- Count identical post titles
- get_page meta query not working, maybe a bug?
- Exec wp query in slow motion to avoid memory error?
- Query by date from custom field
- Remove post type filter added by the plugin in the final query
- How to get more data of a post by wp_query
- pass parameters through variable to WP_QUERY
- What is wrong with my WP_Query Arguments?
- Query of all pages, including children, ordered by meta key
- WP_User_Query orderby meta_val_num
- Query Taxonomy By Page Title
- specific post is not excluded from the loop
- Unable to paginate a custom page query
- How to change the default post type over the loop?
- How to WP Query custom multiple custom taxonomies?
- Sort posts using multiple custom fields and menu_order in single query?
- get_the_terms has strange result since version 6.0
- How to display posts from custom post type category(custom Taxonomy) wise?
- WP Query should show No Posts when tax_query $args taxonomies don’t have associated posts
- Search filter between promo and exact price
- How to make WPQuery custom post type work in Twig / Timber
- get_posts return only first result
- How to allow a variable with “/” in wordpress url
- Bootstrap grid while loop
- Pagination inside the blog page not working
- How to restrict add media library only to images of the same post family?
- How to query most recent post for each author?
- Custom Query Pagination not working on static front page
- Post Template Query with WP_Query?
- Wp Query sort order
- get_posts query caching?
- Adding additional taxonomies to wordpress taxonomy page
- why doesn’t this pre_get_posts code work?
- Query Top Set Custom Taxonomy In Given Timeperiod
- Custom taxonomy and query multi conditions
- Best way to Order Post in Home without a plugin
- Retrieving category pages from subcategory returns empty sets
- WP_query issue with no posts
- How to get query results for the next page
- Add filter to Orderby Parameter using Array
- Iterate through ID’s in loop
- Loop through multiple custom fields with increasing number
- Different number of posts showing in development vs production server
- Multiple loop for “featured” items returns wrong posts
- Get WP_Query query after execution?
- Query string form $_GET[‘value’] is not working as meta value in wp_query
- query_posts problem – need help
- 294 Queries on Mainpage of WordPress
- Pagination on custom post type not working
- I want to capture the last day’s (today) posts in a category in the numbered order in acf
- How do I have multiple metaqueries inside one wordpress query