カスタム投稿タイプ single-○○.phpが読み込まれない
-
閲覧ありがとうございます。初心者です。
カスタム投稿タイプをfunction.phpを編集し作成しています。
使用しているテーマはtwentytwelveです。通常の投稿記事とは異なるデザインにしたいため、カスタム投稿の
記事のテンプレートを作りたいと思っています。http://www.weblogy.co.jp/wptech/entry-81/
こちらを参考に、twentytwelveの記事ページ content-カスタム投稿名.phpを作成し
テーマ下にアップしたのですが、大元のcontent.phpの内容を読み込んでしまっています。独自phpファイルを読み込ませるにはどうしたらよいでしょうか。
以下にfunction.phpの内容を記載します(カスタム投稿名はbooksです)
add_action('init', 'my_technic_init'); function my_technic_init() { $labels = array( 'menu_name' => _x('商品一覧', 'post type general name'), 'singular_name' => _x('商品一覧投稿', 'post type singular name'), 'add_new' => _x('新規追加', 'shop_menu'), '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', 'hierarchical' => false, 'menu_position' => 5, 'supports' => array('title','editor','thumbnail','custom-fields','excerpt','revisions','page-attributes','comments'), 'has_archive' => true, 'rewrite' => true, ); register_post_type('books',$args); register_taxonomy_for_object_type('category', 'books'); register_taxonomy_for_object_type('post_tag', 'books'); } add_action( 'pre_get_posts', 'add_my_post_type' , 10 , 1); function add_my_post_type( $wp_query ) { if ($wp_query->is_main_query() && $wp_query->is_category()) { $wp_query->set( 'post_type', array('post','books')); } } add_action( 'pre_get_posts', 'add_my_post_tag' , 10 , 1); function add_my_post_tag( $wp_query ) { if ($wp_query->is_main_query() && $wp_query->is_tag()) { $wp_query->set( 'post_type', array('post','books')); } }
2件の返信を表示中 - 1 - 2件目 (全2件中)
2件の返信を表示中 - 1 - 2件目 (全2件中)
- トピック「カスタム投稿タイプ single-○○.phpが読み込まれない」には新たに返信することはできません。