Normally, Twenty Fifteen theme does not have an option to show only post excerpt on home page blog loop. It will show complete blog article even we have entered excerpt content while writing article.
I thought instead of showing complete article on home page, it would be better if I only display excerpt and to read complete article, reader would have to visit post. This technique will improve article page views.
But, How to display excerpt when there is no option? was my next question in mind. I did some random search and found that using the_excerpt hook in WordPress will make it work. I found complete code in WordPress forums, thank to forum participant.
How to modify file for post excerpt?
Login to WordPress admin > Appearance > Editor > open content.php file. Look for below code in content.php file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<div class="entry-content"> <?php /* translators: %s: Name of current post */ the_content( sprintf( __( 'Continue reading %s', 'twentyfifteen' ), the_title( '<span class="screen-reader-text">', '</span>', false ) ) ); wp_link_pages( array( 'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentyfifteen' ) . '</span>', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>', 'pagelink' => '<span class="screen-reader-text">' . __( 'Page', 'twentyfifteen' ) . ' </span>%', 'separator' => '<span class="screen-reader-text">, </span>', ) ); ?> </div><!-- .entry-content --> |
And replace it with below code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
<div class="entry-content"> <?php if ( is_single() ) : /* translators: %s: Name of current post */ the_content( sprintf( __( 'Continue reading %s', 'twentyfifteen' ), the_title( '<span class="screen-reader-text">', '</span>', false ) ) ); wp_link_pages( array( 'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentyfifteen' ) . '</span>', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>', 'pagelink' => '<span class="screen-reader-text">' . __( 'Page', 'twentyfifteen' ) . ' </span>%', 'separator' => '<span class="screen-reader-text">, </span>', ) ); else : /* translators: %s: Name of current post */ the_excerpt( sprintf( __( 'Continue reading %s', 'twentyfifteen' ), the_title( '<span class="screen-reader-text">', '</span>', false ) ) ); wp_link_pages( array( 'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentyfifteen' ) . '</span>', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>', 'pagelink' => '<span class="screen-reader-text">' . __( 'Page', 'twentyfifteen' ) . ' </span>%', 'separator' => '<span class="screen-reader-text">, </span>', ) ); endif; ?> </div><!-- .entry-content --> |
Commit the changes and check home page of Twenty Fifteen. Post excerpt will appear instead of full article. If you have manual excerpt content as BeingBlog have, then it will only display manual excerpt. Else, it will auto-generate excerpt from content and display on home page.
Note and Conclusion:
Now we are successfully displaying post excerpt instead of complete article. We hope this will help in generating few page views.
If you have any thoughts, post in below comment box.