Opened 5 years ago
Last modified 7 months ago
#48804 new enhancement
Twenty Twenty: Attach template parts with actions instead of directly including
Reported by: | ianbelanger | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 5.3 |
Component: | Bundled Theme | Keywords: | dev-feedback |
Focuses: | Cc: |
Description
Originally requested on GitHub by @thomasplevy
https://github.com/WordPress/twentytwenty/issues/947
The Problem
Not all custom post types are created equal. Some custom post types are like blog posts where meta information, post author information, and navigation between post types makes sense. Other custom post types behave more like native pages where navigation between pages is undesirable.
This is a pretty generic and blanket statement and it's not always true. Custom post types are custom and the requirement differ greatly depending on the developer creating them.
I am working to add Twenty Twenty theme support for my plugin [LifterLMS](https://github.com/gocodebox/lifterlms) and I have several custom post types which I'd like to be able to remove author and custom post type navigation for.
Given the fact that custom post types utilize template at template-parts/content.php
it is currently only possible for me to remove the navigation and author information by using custom CSS.
The meta information I am able to disable using the filter twentytwenty_disallowed_post_types_for_meta_output
.
Proposed Solution
I'd like to modify the template in question to either be wrapped in a filter which allow the inclusion of template-parts/entry-author-bio.php
and template-parts/navigation.php
to be disabled via a filter.
For example:
if ( is_single() ) { get_template_part( 'template-parts/navigation' ); }
Could become:
if ( is_single() && apply_filters( 'twentytwenty_display_single_navigation', true ) ) { get_template_part( 'template-parts/navigation' ); }
If this does seem like an acceptable addition I'd be more than happy to write and submit the PR but I didn't want to spend time without a blessing from a core contrib or maintainer first.
Thank you for considering this!
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
the template part should be unconditional and there should be a check inside the author-bio template like
(This is actually code I have in my theme.)