Skip to content

Instantly share code, notes, and snippets.

@lunaluna
Last active August 29, 2015 14:06
Show Gist options
  • Save lunaluna/4751013dc95d3f0e422d to your computer and use it in GitHub Desktop.
Save lunaluna/4751013dc95d3f0e422d to your computer and use it in GitHub Desktop.
【WordPress】カスタム投稿タイプ「新着記事(news)」を register_post_type で登録
<?php
// カスタム投稿タイプ「新着記事(news)」
add_action( 'init', 'news_custom_post_type' );
function news_custom_post_type() {
$labels = array(
'name' => _x( '新着記事', 'post type general name' ),
'singular_name' => _x( '新着記事', 'post type singular name' ),
'add_new' => _x( '新しい新着記事を追加', 'news' ),
'add_new_item' => __( '新しい新着記事を追加' ),
'edit_item' => __( '新着記事を編集' ),
'new_item' => __( '新しい新着記事' ),
'view_item' => __( '新着記事を編集' ),
'search_items' => __( '新着記事を探す' ),
'not_found' => __( '新着記事はありません' ),
'not_found_in_trash' => __( 'ゴミ箱に新着記事はありません' ),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'menu_position' => 5,
'hierarchical' => false,
'supports' => array( 'title', 'page-attributes', 'editor' ),
'has_archive' => true
);
register_post_type( 'news', $args );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment