ankara escort bayan ankara escort bayan ankara escort
How to Display All Your WordPress Posts on One Page - WpDevcodes

How to Display All Your WordPress Posts on One Page

Would you like to display all your posts on one page? It’s very simple and easy to Display All Your WordPress Posts on One Page. In this article, we will show you how to display all your WordPress posts on one page without any pagination.

Why Display All Posts on One Page

Some of the blogs prefer to simply display a list of  WordPress post titles and featured images on one page.

Display All WordPress Posts on One Page

There are different ways to display all WordPress posts on one page. You can display posts on a single page with create a shortcode. You can display all posts on a single page using a plugin, and eventually you can display all your posts on a page using a custom template and loop. Using plugin it’s not a good practice to display all WordPress posts on one page for custom wordpress page template.

Create a Custom Template to Display All WordPress Posts on One Page

First create a custom template from where you want to display all WordPress posts on one page. Then add this below code in the template file:

<?php
// start 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 loop -->
</ul>
<?php wp_reset_postdata(); ?>
<?php else : ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>