This post was updated 1226 days ago and some of the ideas may be out of date.
将下面代码添加到主题functions.php里
function san_add_taxonomies_to_pages() {
register_taxonomy_for_object_type( 'post_tag', 'page' );
register_taxonomy_for_object_type( 'category', 'page' );
}
add_action( 'init', 'san_add_taxonomies_to_pages' );
if ( ! is_admin() ) {
add_action( 'pre_get_posts', 'san_category_and_tag_archives' );
}
function san_category_and_tag_archives( $wp_query ) {
$my_san_post_array = array('post','page');
if ( $wp_query->get( 'category_name' ) || $wp_query->get( 'cat' ) )
$wp_query->set( 'post_type', $my_san_post_array );
if ( $wp_query->get( 'tag' ) )
$wp_query->set( 'post_type', $my_san_post_array );
}
参与讨论