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.


try this

$new=new WP_Query(array('posts_per_page'=> 1,'order_by'=>'DESC'));

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.