ワードプレスのSWELL一覧ページでカテゴリータグを表記
parts/post_list/style_normal.phpの一番下Aのと自宅の下に記入でタグを投稿リストに表示させる
</a>
<div class="post-meta-inline">
<span class="post-date"><?php echo esc_html( get_the_date() ); ?></span>
<?php
if ( 'fortune' !== get_post_type() ) {
$terms = get_the_terms( $post->ID, 'area_tag' );
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
// 子タームがある場合は子タームを優先
$child_terms = array_filter( $terms, function( $term ) {
return $term->parent !== 0;
});
$target_term = ! empty( $child_terms ) ? array_shift( $child_terms ) : end( $terms );
echo '<span class="post-cat-inline"><a href="' . esc_url( get_term_link( $target_term ) ) . '">' . esc_html( $target_term->name ) . '</a></span>';
}
}
?>
</div>
</li>
ディスカッション
コメント一覧
まだ、コメントがありません