CMSのコード

WordPress記事一覧を固定ページに表示させる

<section id="primary" class="content-area col-sm-12 col-lg-9">
<main id="main" class="site-main" role="main">


<div class="container">
<div class="row">	
<?php
	$wp_query = new WP_Query();
	$my_posts02 = array(
		'post_type' => 'post',
		'posts_per_page'=> '10',
	);
	$wp_query->query( $my_posts02 );
	if( $wp_query->have_posts() ): while( $wp_query->have_posts() ) : $wp_query->the_post();
?>

<?php
$cat = get_the_category();
$catname = $cat[0]->cat_name; //カテゴリー名
$catslug = $cat[0]->slug; //スラッグ名
?>	

<div class="col-lg-4">
<div class="boxA h-100">
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail( array(300, 168) ); ?>
</a>
<ul class="list-unstyled">
<span class="text-center <?php echo $catslug; ?>"><?php echo $catname; ?></span>	
<li><span class="text-light"><?php the_time('Y年m月d日') ?></span>
<p><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p>
</li>
</ul>
<?php the_excerpt(); ?>
</div>
</div>
<?php endwhile; endif; wp_reset_postdata(); ?>
</div><!-- row END -->
</div><!-- container END -->	
</main><!-- #main -->
</section><!-- #primary -->