[wordpress] 全記事を1ページに出力する
WP_Queryのposts_per_pageを「-1」にすると全件表示になる
あとはpost_typeやpost_statusで微調整
<?php // the query $wpb_all_query = new WP_Query(array('post_type'=>'post', 'post_status'=>'publish', 'posts_per_page'=>-1)); ?> <?php if ( $wpb_all_query->have_posts() ) : ?> <ul> <!-- the loop --> <?php while ( $wpb_all_query->have_posts() ) : $wpb_all_query->the_post(); ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endwhile; ?> <!-- end of the loop --> </ul> <?php wp_reset_postdata(); ?> <?php else : ?> <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p> <?php endif; ?>
参照:
http://www.wpbeginner.com/wp-tutorials/how-to-display-all-your-wordpress-posts-on-one-page/