記事タイトル
<?php the_title(); ?>記事リンク
<?php the_permalink(); ?>日時表示
<?php the_time( get_option( 'date_format' ) ); ?>抜粋
<?php the_excerpt(); ?>文字数を決めた抜粋
40文字の場合
<?php echo wp_trim_words( get_the_content(), 40, '…' ); ?>サムネイルの取得
<?php if (has_post_thumbnail()) : ?>
<?php
echo get_the_post_thumbnail(
get_the_ID(),
'large',
array(
'class' => '',
'alt' => get_the_title(),
)
);
?>
<?php else : ?>
<img src="<?php echo esc_url(get_stylesheet_directory_uri() . '/img/common/no-image.png'); ?>" alt="" width="" height="" class="" >
<?php endif; ?>記事に属するタクソノミーを出力するタグ
「hoge_category」というタクソノミーをリンク付きで「categoryBox」クラスで囲んで出力
<?php
$terms = get_the_terms(get_the_ID(), 'hoge_category');
if (!empty($terms) && !is_wp_error($terms)) :
?>
<div class="categoryBox">
<?php foreach ($terms as $term) : ?>
<a href="<?php echo esc_url(get_term_link($term)); ?>"><span class="<?php echo esc_attr($term->slug); ?>">
<?php echo esc_html($term->name); ?>
</span></a>
<?php endforeach; ?>
</div>
<?php endif; ?>
