[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 05:04:34 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        |  Resolution:
 Keywords:  has-patch     |     Focuses:  template
--------------------------+------------------------------

Comment (by maurisrx):

 This turns out happens because I use **Custom Post Type UI** plugin to
 define my CPT as it converts underscore to hyphen in
 `$post_type_object->name`. If I define the CPT using
 **register_post_type()** directly in my plugin or theme, this issue
 doesn't appear.

 Still, is it better if we use `$post_type_object->slug` to check against
 in the `is_post_type_archive()` instead of `$post_type_object->name`?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/49168#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list