public
Last active

Fix for broken tag archives

  • Download Gist
gistfile1.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14
<?php
 
add_action( 'parse_query', 'tribe_fix_tag_query' );
function tribe_fix_tag_query( $query ) {
if ( $query->is_tag && (array) $query->get( 'post_type' ) != array( TribeEvents::POSTTYPE ) ) {
if ( empty( $query->query_vars['post_type'] ) ) {
$query->query_vars['post_type'] = array( 'post' );
}
if ( ! ( $query->query_vars['post_type'] == array( 'post' ) || $query->query_vars == 'post' ) ) {
remove_action( 'parse_query', array( 'TribeEventsQuery', 'parse_query' ), 50 );
remove_action( 'pre_get_posts', array( 'TribeEventsQuery', 'pre_get_posts' ), 50 );
}
}
}

Thanks for this fix; just discovered my non-event posts weren't showing in tag archives anymore.

Man, thanks so much for this. You save my life =)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.