How to use post excerpt in WordPress Twenty Fifteen theme
In this tutoarial, I will show you, how you can fix the post excerpts issue in the WordPress Twenty Fifteen theme.
Twenty Fifteen theme has greatl layout, Neat & clean content area, great readability settings and other features Twenty Fifteen is going to be favorite of many bloggers. Most of the blog users expect post excerpts on front page. The Twenty Fifteen shows full article on front page, category page, search page etc . There are number of articles on front page, category page, archive pages, search page etc so the length of webpage becomes huge and webpage size also increases. This can be avoided by showing post excerpt in Twenty Fifteen.
For fixing excerpts issue, Look in the content.php which need to be modified for post excerpt.
the_content( sprintf(
__( ‘Continue reading %s’, ‘twentyfifteen’ ),
the_title( ‘‘, ‘‘, false )
) );wp_link_pages( array(
‘before’ => ‘
‘after’ => ‘
‘,
‘link_before’ => ”,
‘link_after’ => ”,
‘pagelink’ => ‘‘ . __( ‘Page’, ‘twentyfifteen’ ) . ‘ %’,
‘separator’ => ‘, ‘,
) );
?>
You can see from the block of code shown above that full content of each post is displayed through the the_content() function. If we change this block of code to show full content for single post and post excerpt for all other cases, then purpose will be solved.
if ( is_single() ) :
Full post content
else :
Post excerpt
endif;
So for now we will have to modify our code. Look below I have modified the code
) );
wp_link_pages( array(
‘before’ => ‘
‘after’ => ‘
‘,
‘link_before’ => ‘‘,
‘link_after’ => ‘‘,
‘pagelink’ => ‘‘ . __( ‘Page’, ‘twentyfifteen’ ) . ‘ %’,
‘separator’ => ‘, ‘,
) );
else :
/* translators: %s: Name of current post */
the_excerpt( sprintf(
__( ‘Continue reading %s’, ‘twentyfifteen’ ),
the_title( ‘‘, ‘‘, false )
) );
wp_link_pages( array(
‘before’ => ‘
‘after’ => ‘
‘,
‘link_before’ => ‘‘,
‘link_after’ => ‘‘,
‘pagelink’ => ‘‘ . __( ‘Page’, ‘twentyfifteen’ ) . ‘ %’,
‘separator’ => ‘, ‘,
) );
endif;
?>
Now we have done!! This piece of code will work perfectly on the wordpress site.