前提・実現したいこと
カスタム投稿タイプのタクソノミーを表示させたい。
下記
$dp_options['show_category']
の代わりに、
カスタム投稿タイプのタクソノミーで指定した「krc_type」を表示させたい。
発生している問題・エラーメッセージ
タクソノミーを取得できずにいます。
該当のソースコード
<header class="p-entry__header"> <?php if ( $dp_options['show_category'] || $dp_options['show_date'] ) : ?> <div class="p-entry__meta"> <?php if ( $dp_options['show_category'] ) : ?> <a class="p-entry__cat" href="<?php echo esc_url( get_category_link( $categories[0]->term_id ) ); ?>"><?php echo esc_html( $categories[0]->name ); ?></a> <?php endif; ?> <?php if ( $dp_options['show_date'] ) : ?> <time class="p-entry__date" datetime="<?php the_time( 'Y-m-d' ); ?>"> <?php the_time( 'Y.m.d' ); ?> </time> <?php endif; ?> </div> <?php endif; ?> <h1 class="p-entry__title"> <?php the_title(); ?> </h1> </header>
<?php $cast_fields = get_post_custom(); //カスタムフィールドを全部取得 $cast_screens = json_decode( $cast_fields[ '_krc_cast_screens' ][ 0 ] ); //画像配列を用意 $cast_type_terms = get_the_terms( $post->ID, 'krc_type' ); //タイプタクソノミーを取得 $cast_grade_terms = get_the_terms( $post->ID, 'krc_grade' ); //グレードタクソノミーを取得 $cast_new_terms = get_the_terms( $post->ID, 'krc_new' ); //新人区分タクソノミーを取得 ?> <div class="main clearfix"> <div> <div class="swiper-container"> <div class="swiper-wrapper"> <div class="swiper-slide"><img src="<?PHP echo esc_url($cast_screens[0]); ?>" alt="<?php echo esc_html($cast_fields['_krc_name'][0]); ?> "/></div> <div class="swiper-slide"><img src="<?PHP echo esc_url($cast_screens[1]); ?>" alt="<?php echo esc_html($cast_fields['_krc_name'][0]); ?> "/></div> <div class="swiper-slide"><img src="<?PHP echo esc_url($cast_screens[2]); ?>" alt="<?php echo esc_html($cast_fields['_krc_name'][0]); ?> "/></div> <div class="swiper-slide"><img src="<?PHP echo esc_url($cast_screens[3]); ?>" alt="<?php echo esc_html($cast_fields['_krc_name'][0]); ?> "/></div> <div class="swiper-slide"><img src="<?PHP echo esc_url($cast_screens[4]); ?>" alt="<?php echo esc_html($cast_fields['_krc_name'][0]); ?> "/></div> </div> <!-- If we need pagination --> <div class="swiper-pagination"></div> <!-- If we need navigation buttons --> <div class="swiper-button-prev"></div> <div class="swiper-button-next"></div> </div> <div><p class="font20 mt20 ac"><?php echo esc_html($cast_fields['_krc_name'][0]); ?> <?php echo esc_html($cast_fields['_krc_age'][0]); ?>歳</p> <?php if ( attend_schedule(get_the_ID()) ) : ?> 本日出勤中 <?PHP endif; ?> </div> <div><p class="mt10 ac">T:<?php echo esc_html($cast_fields['_krc_tall'][0]); ?>B:<?php echo esc_html($cast_fields['_krc_bust'][0]); ?>(<?php echo esc_html($cast_fields['_krc_cups'][0]); ?>)W:<?php echo esc_html($cast_fields['_krc_waist'][0]); ?>H:<?php echo esc_html($cast_fields['_krc_hips'][0]); ?></p></div> <div> <?php echo esc_html($cast_type_terms[0]->name); ?> </div> <div> <?php echo esc_html($cast_grade_terms[0]->name); ?> </div> <div> <?php echo esc_html($cast_new_terms[0]->name); ?> </div> </div> </div>
試したこと
<header class="p-entry__header"> <?php if ( $cast_type_terms['krc_type'] || $dp_options['show_date'] ) : ?> <div class="p-entry__meta"> <?php if ( $cast_type_terms['krc_type'] ) : ?> <a class="p-entry__cat" href="<?php echo esc_url( get_term_link( $cast_type_terms[0]->term_id ) ); ?>"><?php echo esc_html( $cast_type_terms[0]->name ); ?></a> <?php endif; ?> <?php if ( $dp_options['show_date'] ) : ?> <time class="p-entry__date" datetime="<?php the_time( 'Y-m-d' ); ?>"> <?php the_time( 'Y.m.d' ); ?> </time> <?php endif; ?> </div> <?php endif; ?> <h1 class="p-entry__title"> <?php the_title(); ?> </h1> </header>
としてみましたが、エラーになります。
ひとつづつ調べながら命令文を学習していますが、プログラムの知識がないので途方に暮れています。
宜しくお願いします。
補足情報(FW/ツールのバージョンなど)
元はTCD様のテーマファイルです。
http://tcdwp.info/tcd056/
回答1件
あなたの回答
tips
プレビュー