Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #18614, comment 1


Ignore:
Timestamp:
09/07/2011 06:58:37 PM (13 years ago)
Author:
scribu
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #18614, comment 1

    initial v1  
    11What about when you are on a taxonomy page and use 'pre_get_posts' to set an author etc. etc.? We can't apply band-aids like this.
    22
    3 As a workaround for your problem, you can reset {{{$wp_query->queried_object}}} to {{{get_post_type_object( get_post_type() );}}} so that post_type_archive_title() gets the correct thing when it calls get_queried_object().
     3As a workaround for your problem, you can reset {{{$wp_query->queried_object}}} to whatever you need, without modifying Core:
     4
     5{{{
     6function change_queried_object() {
     7  global $wp_query;
     8
     9  if ( is_post_type_archive() )
     10    $wp_query->queried_object = get_post_type_object( get_post_type() );
     11}
     12add_action( 'template_redirect', 'change_queried_object' );
     13}}}