0

I am trying to get the latest inserted post_id by an author using wp_query class. I have to use MAX(wp_posts.ID) in the args of the query i use. Is this somehow possible using wp_query class or do i have to use wpdb::get_results()? Any help appreciated.

0

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;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.