Okay
  Public Ticket #853783
How to display recent posts in homepage
Closed

Comments

  • Pujiang started the conversation

    How to display recent  3 posts in homepage by the style of news-large  ?

    <div id="blog" class="full">
    <?php 

    $squares_paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;

    $squares_args = array(
    'post_type' => 'post',
    'paged' => $squares_paged
    );
    $squares_posts_query = new WP_Query( $squares_args );


    // the loop
    while( $squares_posts_query->have_posts() ){

    $squares_posts_query->the_post();

    get_template_part( 'sections/blog_post_section' );

    }


    ?>
    <!-- /Blog -->



  •  1,974
    Support replied

    Hello

    try

    <div id="blog" class="full"> 

    <?php  

                $squares_paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1; 

                $squares_args = array( 'post_type' => 'post', 'posts_per_page' => 3, 'paged' => $squares_paged ); 

                $squares_posts_query = new WP_Query( $squares_args ); 

               // the loop 

              $posts_no = 1;

               while( $squares_posts_query->have_posts() ){

                            if( $posts_no == 3 ){

                              break; 

                           }

                            $squares_posts_query->the_post();

                            get_template_part( 'sections/blog_post_section' ); 

                           $posts_no++;

                } 

    ?> 

    <!-- /Blog -->


    Thank you.

    Clapat Support

    https://www.clapat.com/

    Review Envato Item Support Policy