Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//固定ページにタグを設定 | |
function add_tag_to_page() { | |
register_taxonomy_for_object_type('post_tag', 'page'); } | |
add_action('init', 'add_tag_to_page'); | |
//タグアーカイブに固定ページを含める | |
function add_page_to_tag_archive( $obj ) { | |
if ( is_tag() ) { | |
$obj->query_vars['post_type'] = array( 'post', 'page' ); | |
} | |
} | |
add_action( 'pre_get_posts', 'add_page_to_tag_archive' ); | |
?> |
Note
Description | 固定ページでタグを使用可能にして、タグアーカイブにも含められるようにする。 |
---|---|
WordPress Ver. | 3.3.1 |
Via | 固定ページに設定したタグをタグ別アーカイブやタグクラウドで利用 |