Including a custom post type in the Archives widget
I have a custom post type called "videos" that I want to include in the Archives widget (stock widget in the TwentyTwelve theme). It DOES already appear on the archives page, but just not in the widget.
I already have
add_action( 'pre_get_posts', 'add_my_post_types_to_query' );
function add_my_post_types_to_query( $query ) {
if ( $query->is_main_query() )
$query->set( 'post_type', array( 'post', 'videos' ) );
return $query;
}
in functions.php - can I modify the IF statement to be something like "if main query OR archive widget query"? How can I do this?
I have a custom post type called "videos" that I want to include in the Archives widget (stock widget in the TwentyTwelve theme). It DOES already appear on the archives page, but just not in the widget.
I already have
add_action( 'pre_get_posts', 'add_my_post_types_to_query' );
function add_my_post_types_to_query( $query ) {
if ( $query->is_main_query() )
$query->set( 'post_type', array( 'post', 'videos' ) );
return $query;
}
in functions.php - can I modify the IF statement to be something like "if main query OR archive widget query"? How can I do this?
No comments:
Post a Comment