2

Is it possible to show the full recent posts rather than excerpt on homepage in grid layout?

Swati
  • 23
  • 6
  • obviously you can.. you can have get_the_content() and can display full posts.. but i dont find any logic behind showing full posts in grid layout as it doesnt help your website speed SEO optimization and many other aspects that make a good decent website... – sagar Aug 07 '17 at 15:00
  • Great thank you, it worked for all posts page. But I am having requirement to show full 4 recent posts on homepage in grid layout. It will be on internal server so SEO will not be an issue so can you please suggests how can we achieve that? – Swati Aug 07 '17 at 15:47
  • To get that grid layout and get those recent posts in grid you can always use WP Query where you can have 'order'=>'DESC' parameter in query https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters – sagar Aug 08 '17 at 04:44

2 Answers2

0

Use the_content() or echo get_the_content() instead the_excerpt() or echo get_the_excerpt() respectively . Thanks

deemi-D-nadeem
  • 2,343
  • 3
  • 30
  • 71
Souvik Sikdar
  • 777
  • 5
  • 11
0

You can always add your html into the below code

<?php
    $args = array(
        'post_type'   =>'post',
        'posts_per_page' => 4,
        'order'           =>'DESC'
        );

     $the_query = new WP_Query($args);
     if ( $the_query->have_posts() ) :
        while ( $the_query->have_posts() ) :
            $the_query->the_post();
      ?>
      <div class="gridlayout">
      <?php the_content(); ?>
      </div>

    <?php endwhile; wp_reset_query(); endif; ?>
sagar
  • 590
  • 4
  • 11
  • Hey sagar, thank you for the code, I tried it in my custom page template but it shows me an error "Fatal error: Call to a member function have_posts() on null in" Can you please advise me why I am getting this error? – Swati Aug 08 '17 at 20:32
  • try it again i didnt check that in my code so there was a problem – sagar Aug 09 '17 at 05:30
  • Hey can we create a "short code" for this function, actually i want to use it on any page or post. – Swati Aug 09 '17 at 14:02
  • yes you can always use shortcode anywhere in wordpress and please mark it as correct – sagar Aug 10 '17 at 06:50
  • Hey sagar, Can you please advise me how to use this as a shortcode actually I did create a function and used it as shortcode its working but the contnent after that is floating(appending) with that, I tried to clear the grid layout float but not working can you please help me with this? – Swati Aug 10 '17 at 13:17