archive.php,category.php
タイトル
category.phpにて、ページタイトルを出力する方法
<h1><?php single_cat_title(); ?></h1>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php
$categories = get_the_category();
if( $categories ){
echo '<ul>';
foreach( $categories as $category ){
echo '<li><a href="' . get_category_link( $category->term_id ) . '">'
. $category->name . '</a></li>';
}
echo '</ul>';
}
?>
<?php endwhile; else : ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
↓find-ochanomizu.ver
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<a href="<?php the_permalink(); ?>">
<article class="animated">
<h3><?php the_title(); ? ></h3>
<p class="category"><?php
$category = get_the_category();
echo $category[0]->cat_name;
?></p>
<p class="image"><img src="<?php
the_post_thumbnail_url('large'); ?>" alt="<?php the_title(); ?>">
</p>
</article>
</a>
<?php endwhile; else : ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>