appkitcut
4/5/2019 - 4:57 PM

人気な記事一覧を出力

人気な記事一覧を出力したい部分に以下のコードをコピペでOK。

<?php
// views post metaで記事のPV情報を取得する
setPostViews(get_the_ID());

// ループ開始
query_posts('meta_key=post_views_count&orderby=meta_value_num&posts_per_page=5&order=DESC'); while(have_posts()) : the_post(); ?>

<!-- サムネイルの表示 -->
<div class="col-sm-4 col-xs-4">
	<a href="<?php echo get_permalink(); ?>">
		<?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'post-thumbnail'); } ?>
	</a>
</div>

<!-- タイトルの表示 -->
<div class="col-sm-8 col-xs-8">
	<p>
		<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
	</p>
</div>

<?php endwhile; ?>