[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 19:48:51 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:  closed
 Priority:  normal          |   Milestone:
Component:  Template        |     Version:  3.3
 Severity:  normal          |  Resolution:  wontfix
 Keywords:  has-patch       |
----------------------------+----------------------

Comment (by wonderboymusic):

 Replying to [comment:3 scribu]:
 > Ok, and what happens if 'post_type' is set to an array by some other
 code that alters $wp_query?

 funny you should ask - I did some testing that looks at exactly that -
 removes the tax_query and instead sets post_type (also tested with
 tax_query AND post_type set to something custom)

 the original post_type was "emusic_icon" and I added "post" and
 "emusic_spotlight"

 {{{
 // altered function
 function post_type_archive_title( $prefix = '', $display = true ) {
     global $wp_query;
     var_dump( $wp_query );
     var_dump( get_post_type_object( get_post_type() ) ); exit();
     if ( ! is_post_type_archive() )
                 return;

         $post_type_obj = get_post_type_object( get_post_type() );
         $title = apply_filters('post_type_archive_title',
 $post_type_obj->labels->name );

         if ( $display )
                 echo $prefix . $title;
         else
                 return $title;
 }
 }}}

 Here's the output for $wp_query with an Array of post_types:

 {{{
 object(WP_Query)#129 (47) {
   ["query_vars"]=>
   array(58) {
     ["post_type"]=>
     array(3) {
       [0]=>
       string(4) "post"
       [1]=>
       string(11) "emusic_icon"
       [2]=>
       string(16) "emusic_spotlight"
     }
 .....
 }}}

 Here's the output for get_post_type_object( get_post_type() ) - returns
 the ORIGINAL post_type:

 {{{
 object(stdClass)#354 (26) {
   ["labels"]=>
   object(stdClass)#356 (14) {
     ["name"]=>
     string(5) "Icons"
     ["singular_name"]=>
     string(4) "Icon"
     ["add_new"]=>
     string(7) "Add New"
     ["add_new_item"]=>
     string(12) "Add New Icon"
     ["edit_item"]=>
     string(9) "Edit Icon"
     ["new_item"]=>
     string(8) "New Icon"
     ["view_item"]=>
     string(9) "View Icon"
     ["search_items"]=>
     string(12) "Search Icons"
     ["not_found"]=>
     string(14) "No Icons found"
     ["not_found_in_trash"]=>
     string(23) "No Icons found in Trash"
     ["parent_item_colon"]=>
     NULL
     ["all_items"]=>
     string(5) "Icons"
     ["menu_name"]=>
     string(5) "Icons"
     ["name_admin_bar"]=>
     string(4) "Icon"
   }
   ["description"]=>
   string(0) ""
   ["publicly_queryable"]=>
   bool(true)
   ["exclude_from_search"]=>
   bool(false)
   ["capability_type"]=>
   string(4) "post"
   ["map_meta_cap"]=>
   bool(true)
   ["_builtin"]=>
   bool(false)
   ["_edit_link"]=>
   string(16) "post.php?post=%d"
   ["hierarchical"]=>
   bool(false)
   ["public"]=>
   bool(true)
   ["rewrite"]=>
   array(4) {
     ["slug"]=>
     string(15) "music-news/icon"
     ["with_front"]=>
     bool(true)
     ["pages"]=>
     bool(true)
     ["feeds"]=>
     bool(true)
   }
   ["has_archive"]=>
   string(16) "music-news/icons"
   ["query_var"]=>
   string(11) "emusic_icon"
   ["register_meta_box_cb"]=>
   object(Closure)#353 (1) {
     ["static"]=>
     array(2) {
       ["type"]=>
       string(11) "emusic_icon"
       ["callback"]=>
       object(Closure)#352 (1) {
         ["parameter"]=>
         array(1) {
           ["$type"]=>
           string(10) "<required>"
         }
       }
     }
   }
   ["taxonomies"]=>
   array(5) {
     [0]=>
     string(6) "region"
     [1]=>
     string(5) "genre"
     [2]=>
     string(8) "location"
     [3]=>
     string(8) "post_tag"
     [4]=>
     string(8) "category"
   }
   ["show_ui"]=>
   bool(true)
   ["menu_position"]=>
   NULL
   ["menu_icon"]=>
   NULL
   ["permalink_epmask"]=>
   int(1)
   ["can_export"]=>
   bool(true)
   ["show_in_nav_menus"]=>
   bool(true)
   ["show_in_menu"]=>
   bool(false)
   ["show_in_admin_bar"]=>
   bool(false)
   ["name"]=>
   string(11) "emusic_icon"
   ["cap"]=>
   object(stdClass)#355 (14) {
     ["edit_post"]=>
     string(9) "edit_post"
     ["read_post"]=>
     string(9) "read_post"
     ["delete_post"]=>
     string(11) "delete_post"
     ["edit_posts"]=>
     string(10) "edit_posts"
     ["edit_others_posts"]=>
     string(17) "edit_others_posts"
     ["publish_posts"]=>
     string(13) "publish_posts"
     ["read_private_posts"]=>
     string(18) "read_private_posts"
     ["read"]=>
     string(4) "read"
     ["delete_posts"]=>
     string(12) "delete_posts"
     ["delete_private_posts"]=>
     string(20) "delete_private_posts"
     ["delete_published_posts"]=>
     string(22) "delete_published_posts"
     ["delete_others_posts"]=>
     string(19) "delete_others_posts"
     ["edit_private_posts"]=>
     string(18) "edit_private_posts"
     ["edit_published_posts"]=>
     string(20) "edit_published_posts"
   }
   ["label"]=>
   string(5) "Icons"
 }
 }}}

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


More information about the wp-trac mailing list