1

I'm using below wp-cli command to get latest post ID:

wp post list --order='DESC' --orderby='ID' --field='ID' | head -1

This, however is inefficient as all posts are retrieved from DB and then head limits the number of returned posts.

Is there a way to limit the number of returned posts using wp query?

1 Answer 1

2

Simply add:

--posts_per_page=1

to limit the queried items to a single item.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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