By default, the
post_status of a query is set to
publish for anonymous users on the front end. It is not set in any WP_ADMIN context, including Ajax queries.
Queries on the front end for logged-in users will also contain an OR statement for private posts created by the logged-in user, even if that user is not part of the site. This will reduce the effectiveness of MySQL indexes, specifically the
The same is true for
post_type. If it is known that only a certain
post_type will match the rest of the query (for example, for a taxonomy, meta, or just a general query), adding the
post_type as well as the
post_status will help MySQL better utilize the indexes at its disposal.
Last updated: November 15, 2023