カスタム投稿タイプを作成したのですが、いざ新規投稿でページを作成しても本文が反映されない状況です。
"最新情報登録"の投稿タイプで新規作成で入力した内容をnewsinfo.phpに反映する予定です。
お手数ですが原因と解決策を教えていただけますでしょうか?
下記、該当するfunctions.phpとnewsinfo.phpの情報になります。
お手数ですがご教授いただけますと幸いです。
functions.php
* カスタム投稿タイプ * */ function bourgeon_create_post_type(){ register_post_type('newsinfo', array( 'labels' => array( 'name' => '最新情報登録', 'singular_name' => '最新情報登録', ), 'public' => true, 'menu_position' => 5, 'has_archive' => true, 'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'custom-fields', ), ) ); register_post_type('kamei', array( 'labels' => array( 'name' => '加盟店登録', 'singular_name' => '加盟店登録', ), 'public' => true, 'menu_position' => 5, 'has_archive' => true, 'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'custom-fields', ), ) ); register_post_type('hikamei', array( 'labels' => array( 'name' => '非加盟店登録', 'singular_name' => '非加盟店登録', ), 'public' => true, 'menu_position' => 5, 'has_archive' => true, 'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'custom-fields', ), ) ); } add_action('init','bourgeon_create_post_type',1); /** * カスタム投稿タイプにカスタム分類を作成する * */ function bourgeon_create_taxonomies(){ //最新情報登録 $labels=array( 'name' => 'news / info', 'singular_name' => 'news / info', ); register_taxonomy('type1',array('newsinfo'), array( 'hierarchical' => true, 'labels' => $labels, 'show_ui'=> true, 'show_admin_column'=> true, 'show_in_nav_menus'=> true, ) ); //加盟店登録 $labels=array( 'name' => 'カテゴリー', 'singular_name' => 'カテゴリー', ); register_taxonomy('type2',array('kamei'), array( 'hierarchical' => true, 'labels' => $labels, 'show_ui'=> true, 'show_admin_column'=> true, 'show_in_nav_menus'=> true, ) ); //非加盟店登録 $labels=array( 'name' => 'カテゴリー', 'singular_name' => 'カテゴリー', ); register_taxonomy('type3',array('hikamei'), array( 'hierarchical' => true, 'labels' => $labels, 'show_ui'=> true, 'show_admin_column'=> true, 'show_in_nav_menus'=> true, ) ); } add_action('init','bourgeon_create_taxonomies',0); ?>
newsinfo.php
if(have_posts()): while(have_posts()): the_post(); ?> <article id="post-<?php the_ID(); ?>"<?php post_class(); ?>> <header class="entry-header"> <h2 class="entry-title"><?php the_title(); ?></h2> <p class="product-lead"><?php echo esc_html (get_field('product-lead')); ?></p> <div class="terms"> <?php $terms = get_the_terms($post->ID,'type1'); if(!is_wp_error($terms) && $terms): foreach($terms as $term): ?> <span class="label product-<?php echo esc_attr($term->slug); ?>"><?php echo esc_html($term->name); ?></span> <?php endforeach; endif; ?> </div> </header> <section class="entry-content"> <div class="product"> <?php the_content(); ?> </div> </section> </article> <?php endforeach; endif; ?>
回答1件
あなたの回答
tips
プレビュー