Skip to content

Query: Add is_post_format_archive() conditional tag - #12927

Open
irozum wants to merge 2 commits into
WordPress:trunkfrom
irozum:enhancement/23749-is-post-format-archive
Open

Query: Add is_post_format_archive() conditional tag#12927
irozum wants to merge 2 commits into
WordPress:trunkfrom
irozum:enhancement/23749-is-post-format-archive

Conversation

@irozum

@irozum irozum commented Aug 7, 2026

Copy link
Copy Markdown

Adds a new is_post_format_archive( $post_formats = '' ) conditional tag, plus the matching WP_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-intuitive is_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 like is_category()/is_tag()/is_tax(): a thin WP_Query method delegating to is_tax( 'post_format', ... ), plus a global wrapper function in query.php with the standard "query hasn't run yet" _doing_it_wrong() guard. is_post_format_archive was also added to the shared assertQueryTrue() conditional list in abstract-testcase.php (alongside is_post_type_archive) so it participates in the existing cross-conditional assertions, and it's automatically covered by the existing data_conditional_tags_trigger_doing_it_wrong_and_return_false_if_wp_query_is_not_set data provider since that discovers all is_* methods on WP_Query dynamically.

$post_formats accepts a single format string (e.g. 'aside') or an array of formats, without the post-format- slug prefix, matching the ergonomics of has_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.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props irozum.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Test using WordPress Playground

The 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

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant