[WordPress]WP_Queryで投稿の順番を取得して表示する方法

WordPress
スポンサーリンク

目次

WP_Query

<?php
$args = array(
	'post_type' => 'post',
	'posts_per_page' => 10
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) :
while ( $the_query->have_posts() ) : $the_query->the_post();?>
	<?php echo $the_query->current_post + 1;?>
<?php endwhile;?>
<?php endif;?>
<?php wp_reset_postdata();?>

コメント

タイトルとURLをコピーしました