How to show all wordpress post in single page ?

How to show all wordpress post in single page ?

Add Comment



  • 1 Answer(s)
    <?php $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; ?>

    In this section: posts_per_page mean – number of post you need to show on the page -1 mean unlimited

    Answered on June 29, 2017.
    Add Comment



  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.