Are you looking to display all the WordPress posts on one page without using any WordPress plugin, then you are on the right page. In this post, I have shared a simple code snippets which will display the all Published post from your WordPress site.
Create a template inside your theme folder and copy paste the below code after template header. For displaying all posts that has been published. You have to use post_per_page=’-1′.
$args = array(
'orderby' => 'ID',
'post_status' => 'publish',
'order' => 'DESC',
'posts_per_page' => -1 // this will retrive all the post that is published
$result = new WP_Query( $args );
if ( $result-> have_posts() ) : ?>
<?php while ( $result->have_posts() ) : $result->the_post(); ?>
<?php the_title(); ?>
<?php endwhile; ?>
<?php endif; wp_reset_postdata(); ?>
Add the below code in top of your template file.
* Template Name: Add Your Template Page Name Here
* @package WordPress
* @subpackage Twenty_Fourteen
* @since Twenty Fourteen 1.0
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.