Skip to content

Instantly share code, notes, and snippets.

@mypacecreator
Last active December 22, 2015 03:48
Show Gist options
  • Save mypacecreator/6412406 to your computer and use it in GitHub Desktop.
Save mypacecreator/6412406 to your computer and use it in GitHub Desktop.
カスタム投稿タイプ+カスタムタクソノミー作成でよく使うやつ
<?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