Repository navigation
Twenty Twenty: Fix post meta wrapper not rendering when action hooks add content without default meta - #11769
shrivastavanolo wants to merge 2 commits into
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. |
fb47a6f to
d8914be
Compare
sabernhardt
left a comment
There was a problem hiding this comment.
Test Report
Patch tested: https://github.com/WordPress/wordpress-develop/pull/11769.diff
Steps taken
- Activate Twenty Twenty.
- Create and publish two posts: one with at least one tag and one with zero tags.
- Use actions to add custom list items at beginning and end of the meta list.
- Add each filter example—or a combination of them—to change the default output.
- Reset the actions and filters.
- Apply the patch.
- Repeat steps 3 and 4 to test how the same actions and filters work with the patch.
Code samples
I added these in a custom must-use plugin, but you could test with a child theme.
// Add list items at beginning and end.
add_action( 'twentytwenty_start_of_post_meta_list', function() {
echo '<li>twentytwenty_start_of_post_meta_list</li>';
});
add_action( 'twentytwenty_end_of_post_meta_list', function() {
echo '<li>twentytwenty_end_of_post_meta_list</li>';
});
// Filter 1: Replace single-top meta with tags list.
add_filter( 'twentytwenty_post_meta_location_single_top', function() {
return array( 'tags' );
});
// Filter 2: Replace single-bottom meta with 'sticky' (if the posts are *not* sticky).
add_filter( 'twentytwenty_post_meta_location_single_bottom', function() {
return array( 'sticky' );
});
// Filters 3a +3b: Remove default meta in either location with 'foo' as a dummy array value.
add_filter( 'twentytwenty_post_meta_location_single_top', function() {
return array( 'foo' );
});
add_filter( 'twentytwenty_post_meta_location_single_bottom', function() {
return array( 'foo' );
});
// Filters 4a + 4b: Remove all post meta—even custom meta—from either location.
add_filter( 'twentytwenty_post_meta_location_single_top', '__return_empty_array' );
add_filter( 'twentytwenty_post_meta_location_single_bottom', '__return_empty_array' );
Screenshots
✅ With default post meta, the patch does not change the output.
| Before patch | With patch |
|---|---|
![]() |
![]() |
![]() |
![]() |
When I added start and end list items in both locations, they appeared in the top and bottom except when the post had zero tags. With the patch, the custom list items display even when the post has no tags.
| Before patch | With patch |
|---|---|
![]() |
![]() |
![]() |
![]() |
When I used array( 'tags' ) for meta in the top location, the custom list items similarly did not display before the patch when there were zero tags. Again, with the patch, the custom list items display even when the post has no tags.
| Before patch | With patch |
|---|---|
![]() |
![]() |
![]() |
![]() |
When I used array( 'sticky' ) in the bottom location, after applying the patch, the custom list items displayed without showing anything else (because the posts were not sticky).
| Before patch | With patch |
|---|---|
![]() |
![]() |
![]() |
![]() |
The screenshots below show results from setting array( 'tags' ) in the top location and array( 'sticky' ) in the bottom location, at the same time.
| Before patch | With patch |
|---|---|
![]() |
![]() |
![]() |
![]() |
Using array( 'foo' ) removes any default meta, but the post shows any custom items with the patch applied. In the top location, that removes the author, date, comments, and possibly a note that the post is sticky.
| Before patch | With patch |
|---|---|
![]() |
![]() |
![]() |
![]() |
array( 'foo' ) in the bottom location:
| Before patch | With patch |
|---|---|
![]() |
![]() |
![]() |
![]() |
An empty array removes any meta, including custom items. These screenshots show the top location without any meta:
| Before patch | With patch |
|---|---|
![]() |
![]() |
![]() |
![]() |
Empty array in the bottom location:
| Before patch | With patch |
|---|---|
![]() |
![]() |
![]() |
![]() |
Environment
- WordPress: 7.1-alpha-62161-src
- Subdirectory: No
- PHP: 8.3.14
- Server: Apache/2.4.62 (Win64) PHP/8.3.14 mod_fcgid/2.3.10-dev
- Database: mysqli (Server: 9.1.0 / Client: mysqlnd 8.3.14)
- Browser: Firefox
- OS: Windows 11
- Theme: Twenty Twenty 3.1
- MU Plugin: SVN
|
This branch needs a refresh, if we can get that we can consider it. |
…ction hooks when no default meta exists
Co-authored-by: Stephen A. Bernhardt <sabernhardt@yahoo.com>
d8914be to
a81c4d4
Compare




































twentytwenty_get_post_meta()uses a$has_metaflag to decide whether to return the meta wrapper HTML. This flag is only set totruewhen default meta fields (author, date, tags, etc.) are present. As a result, content added via thetwentytwenty_start_of_post_meta_listandtwentytwenty_end_of_post_meta_listaction hooks is silently discarded when no default meta exists — for example, on a post with no tags in thesingle-bottomlocation.This fix checks whether the output buffer contains any content after stripping tags. The meta wrapper is now returned if either default meta or hook content is present.
Trac ticket: https://core.trac.wordpress.org/ticket/58223
Use of AI Tools
AI assistance: Yes
Tool(s): Claude
Model(s): Opus 4.6
Used for: Initial code skeleton and PR description; final implementation and tests were reviewed and edited by me.
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.