[wp-trac] [WordPress Trac] #49168: is_post_type_archive( $post_types = '' ) doesn't work with underscore (_)
WordPress Trac
noreply at wordpress.org
Sat Jan 11 04:18:59 UTC 2020
#49168: is_post_type_archive( $post_types = '' ) doesn't work with underscore (_)
--------------------------+-----------------------------
Reporter: maurisrx | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: 5.3.2
Severity: normal | Keywords:
Focuses: template |
--------------------------+-----------------------------
I define my custom post type slug using underscore, e.g. 'post_type'. But
it always returns false when I try to check with `is_post_type_archive(
'post_type' )`. It turns out I have to use hyphen (-) instead of
underscore (_), e.g. `is_post_type_archive( 'post-type' )`.
It is confusing because I defined the CPT using underscore, but the
`is_post_type_archive()` doesn't accept underscore.
The issue is `is_post_type_archive()` uses `$post_type_object->name`
instead of `$post_type_object->slug` to check against. For backward
compatibility, should we accept both underscore (_) and hyphen (-) in the
`is_post_type_archive( $post_types )`?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/49168>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list