Opened 7 years ago
Last modified 3 weeks ago
#43613 new defect (bug)
Default post format setting does not respect theme support
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Post Formats | Keywords: | has-patch |
Focuses: | administration | Cc: |
Description
In options-writing.php
, the Default Post Format
setting does not check whether the current theme supports the built-in formats. Would it not be more intuitive if only the formats supported by the current theme were in the list to select? Then a description could be added underneath to say "these are the formats supported by the currently selected theme".
Alternatively, there could be a filter added to get_post_format_strings
in wp-includes/post-formats.php
to allow themes/plugins to remove available formats from this list.
Change History (5)
#3
follow-up:
↓ 4
@
2 years ago
- Keywords needs-patch added
- Version trunk deleted
I removed the version again because the issue is not new to trunk
(see Trac version in the handbook). The ticket was opened when 4.9 was available, and this could go all the way back to 3.6.
#4
in reply to:
↑ 3
@
2 years ago
Replying to sabernhardt:
I removed the version again because the issue is not new to trunk
Ah perfect, thank you for the explanation!
This ticket was mentioned in PR #9059 on WordPress/wordpress-develop by @sahilgidwani.
3 weeks ago
#5
- Keywords has-patch added; needs-patch removed
This PR updates the options-writing.php
admin screen to ensure that the "Default Post Format" dropdown only displays post formats explicitly supported by the currently active theme. Previously, this dropdown listed all core post formats, regardless of whether the theme declared support via add_theme_support( 'post-formats', [...] )
.
This behavior led to possible misconfiguration, user confusion, and inconsistent behavior between the settings screen and the post editor (which already hides unsupported formats).
#### Previous Logic
The dropdown was populated using:
$post_formats = get_post_format_strings();
unset( $post_formats['standard'] );
This included all formats regardless of theme support.
#### New Logic
Replaced with:
$supported_formats = get_theme_support( 'post-formats' );
if ( is_array( $supported_formats ) && isset( $supported_formats[0] ) ) {
$post_formats = array_intersect_key( get_post_format_strings(), array_flip( $supported_formats[0] ) );
} else {
$post_formats = array();
}
This ensures only the intersection of supported formats and registered format strings is used. The standard
format remains available separately, as it is treated as the fallback/default.
### Why This Matters
- Prevents the admin UI from offering unsupported options.
- Aligns admin settings with front-end and post editor behavior.
- Avoids storing invalid default values in
default_post_format
which have no effect on post rendering. - Reduces user confusion by not listing formats that won’t have any visible impact.
### Edge Cases Handled
- If the theme supports no formats, only the
standard
option is shown. - If the theme supports all formats, the dropdown behavior remains unchanged.
- Backward compatibility is preserved, as the underlying storage and post format API remains the same.
Trac Link: https://core.trac.wordpress.org/ticket/43613
I just came here to submit this exact issue. None of our themes use Post Formats (and I think they're becoming rarer and rarer). When users visit Settings->Writing, though, they are presented with a variety of Post Formats that don't even really exist and mean nothing, and thus a confusing setting that has no impact.
I think the Default Post Format option should only exist if the current theme supports Post Formats.