[wp-trac] [WordPress Trac] #18614: post_type_archive_title doesn't work when tax_query is added to wp_query

WordPress Trac wp-trac at lists.automattic.com
Wed Sep 7 17:52:04 UTC 2011


#18614: post_type_archive_title doesn't work when tax_query is added to wp_query
----------------------------+-----------------------------
 Reporter:  wonderboymusic  |      Owner:
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Template        |    Version:  3.3
 Severity:  normal          |   Keywords:  has-patch
----------------------------+-----------------------------
 post_type_archive_title( ) gets called by wp_title( ) on Custom Post Type
 archive pages

 To get the data for the post type object,  post_type_archive_title( )
 calls get_queried_object( ). This is problematic. If the query has been
 altered in any way (such as adding a tax_query in pre_get_posts filter),
 get_queried_object( ) will probably return a term, not a post type object.

 Hence, accessing $post_type_obj->labels will fail and their will be no
 title returned

 {{{
 //old potentially broken way
 $post_type_obj = get_queried_object();

 // new doesn't break way
 $post_type_obj = get_post_type_object( get_post_type() );
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/18614>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list