[wp-trac] [WordPress Trac] #48804: Twenty Twenty: Attach template parts with actions instead of directly including
WordPress Trac
noreply at wordpress.org
Tue Nov 26 21:54:34 UTC 2019
#48804: Twenty Twenty: Attach template parts with actions instead of directly
including
---------------------------+------------------------------
Reporter: ianbelanger | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Bundled Theme | Version: 5.3
Severity: normal | Resolution:
Keywords: 2nd-opinion | Focuses:
---------------------------+------------------------------
Comment (by joyously):
As commented on GitHub:
It makes sense to me to put the checks into the individual template files
instead of in content.php and duplicated in content-cover.php and that is
called with a post type parameter, so it could be any other post type
also, in a child theme.
The part for the author bio should check for post type support, and a
filter is always useful.
So instead of
{{{
if ( is_single() ) {
get_template_part( 'template-parts/entry-author-bio' );
}
}}}
the template part should be unconditional and there should be a check
inside the author-bio template like
{{{
$this_post_type = get_post_type();
if ( post_type_supports( $this_post_type, 'author' ) &&
! in_array( $this_post_type, apply_filters(
'twentytwenty_posttypes_no_author', array( 'page' ) ) ) ) {
if ( is_attachment() || is_single() )
}}}
''(This is actually code I have in my theme.)''
--
Ticket URL: <https://core.trac.wordpress.org/ticket/48804#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list