Query: Add is_post_format_archive() conditional tag - #12927
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Adds a new
is_post_format_archive( $post_formats = '' )conditional tag, plus the matchingWP_Query::is_post_format_archive()method, so themes and plugins can check whether the current query is for a post format archive without going through the less-intuitiveis_tax( 'post-format', 'post-format-image' )call and manually prefixing term slugs.The implementation mirrors the existing
has_post_format()helper's slug-prefixing pattern and follows the exact structure of sibling conditional tags likeis_category()/is_tag()/is_tax(): a thinWP_Querymethod delegating tois_tax( 'post_format', ... ), plus a global wrapper function inquery.phpwith the standard "query hasn't run yet"_doing_it_wrong()guard.is_post_format_archivewas also added to the sharedassertQueryTrue()conditional list inabstract-testcase.php(alongsideis_post_type_archive) so it participates in the existing cross-conditional assertions, and it's automatically covered by the existingdata_conditional_tags_trigger_doing_it_wrong_and_return_false_if_wp_query_is_not_setdata provider since that discovers allis_*methods onWP_Querydynamically.$post_formatsaccepts a single format string (e.g.'aside') or an array of formats, without thepost-format-slug prefix, matching the ergonomics ofhas_post_format().Trac ticket: https://core.trac.wordpress.org/ticket/23749
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: Implementation, tests, and PR description. Reviewed by Igor Rozum.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.