Last active
December 22, 2015 03:48
-
-
Save mypacecreator/6412406 to your computer and use it in GitHub Desktop.
カスタム投稿タイプ+カスタムタクソノミー作成でよく使うやつ
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 mypace_custom_post_type() { | |
register_post_type( 'voice', array( | |
'label' => 'お客様の声', | |
'public' => true, | |
'exclude_from_search' => false, | |
'hierarchical' => false, | |
'menu_position' => 5, | |
'has_archive' => true, | |
'rewrite' => true, | |
'supports' => array( | |
'title', 'editor', 'thumbnail', 'excerpt', 'custom-fields', 'revisions' | |
) | |
) | |
); | |
register_taxonomy( | |
'voicecat', //slug | |
'voice', //紐付けるポストタイプ | |
array( | |
'hierarchical' => true, | |
'label' => 'お客様の声カテゴリー', | |
'query_var' => true, | |
'rewrite' => true | |
) | |
); | |
register_post_type( 'faq', array( | |
'label' => 'よくあるご質問', | |
'public' => true, | |
'exclude_from_search' => false, | |
'hierarchical' => false, | |
'menu_position' => 5, | |
'has_archive' => true, | |
'rewrite' => true, | |
'supports' => array( | |
'title', 'editor', 'thumbnail', 'custom-fields','excerpt', 'revisions' | |
) | |
) | |
); | |
register_taxonomy( | |
'faqcat', //slug | |
'faq', //紐付けるポストタイプ | |
array( | |
'hierarchical' => true, | |
'label' => '質問カテゴリー', | |
'query_var' => true, | |
'rewrite' => true | |
) | |
); | |
flush_rewrite_rules( false ); | |
} | |
add_action( 'init', 'mypace_custom_post_type' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment