WordPress/twentytwenty

Custom post type that doesn't support author, shows author

joyously opened this issue · 3 comments

Create a custom post type and specify that it does not support author (similar to Page).
Create a new post of that post type.
View that post on the front end.
The author is shown under the title, even though the post type does not support author.

This is an interesting one that I actually don't think I've ever noticed before but I can see how this would be a problem if a post type didn't want an author to be connected to a post on the frontend.

Are there any core functions that already handle this kind of thing? I can't think of any at the moment but surely this is a common enough thing that there is something from core we can use to work this out?

This is how my theme does it

$this_post_type = get_post_type();
if ( post_type_supports( $this_post_type, 'author' ) &&
	! in_array( $this_post_type, apply_filters( 'twenty8teen_posttypes_no_author', array( 'page' ) ) ) ) {

This issue is written for author, but custom post types can choose not to have title or excerpt etc.
I just picked the most common one to focus on here.