[wp-trac] [WordPress Trac] #38910: `is_post_type_archive()` return true when the current page is tag archive

WordPress Trac noreply at wordpress.org
Wed Nov 23 02:03:55 UTC 2016


#38910: `is_post_type_archive()` return true when the current page is tag archive
--------------------------+-----------------------------
 Reporter:  yaquawa       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  4.6.1
 Severity:  normal        |   Keywords:
  Focuses:  template      |
--------------------------+-----------------------------
 See if you register a post type "fruit". And you have a tag "sample-tag".

 When you access:
 http://localhost/tag/sample-tag/?post_type=fruit

 You'll be taken to the post type archive page(template) rather than the
 tag archive page even the URL is telling you this is a tag archive page.

 This is because the `is_post_type_archive()` is called earlier than
 `is_tag()` in `wp-includes/template-loader.php`.  It should never depend
 on the order of condifional functions be called, I believe this is a
 serious bug.

 `is_post_type_archive()` should return false when the current page is NOT
 a post type archive page.

 To get a stricter result of `is_post_type_archive()`, it should check if
 the current `queried_object` is a WP_Post type or not.
 If you are viewing a tag archive, the `queried_object` is an instance of
 `WP_Term` , obviously, this is NOT a "post type archive" page at all.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/38910>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list