Here in this post I will show you how to add post excerpts, display thumbnail of your post which removes featured image from your single post and customize Read More link in your WordPress Twenty Thirteen Theme.
Post Excerpts is a short note of our posts to the visitors and it also reduces the web page loading time by showing a short summary of your posts.
By Default WordPress Twenty Thirteen show post Excerpts only for search action, And to show these Excerpts for all Pages (Home, Category, Tag, Author and Archive Pages) it can be done by slight changes in content.php and function.php pages.
Editing Template Files
[table “151” not found /]Open content.php file around Line No 33 you can see
1 |
<?php if ( is_search() ) : // Only display Excerpts for Search ?> |
This line tells to display Excerpts only to a search page, And to display Excerpts on all other pages modify the code as below
1 |
<?php if ( is_search() || is_home() || is_category () || is_author() || is_tag() || is_archive() ) : // Only display Excerpts for Search ?> |
Save the file and refresh your website.
Now you can see the Post Excerpts on Home, Category, Author, Tag, Archive Pages
To add a Thumbnail Image And Read More Link To Excerpt Posts
Open function.php file, add the following code at the end
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
// Add 140x140 Image to Excerpts add_image_size('excerpt-thumbnail', 140, 140, true); // Remove […] from Excerpt and add Read More Link function change_excerpt_more() { function new_excerpt_more($more) { // Use .read-more to style the link return '...<span class="continue-reading"> <a href="' . get_permalink() . '">'.'Read More »' . '</a></span>'; } add_filter('excerpt_more', 'new_excerpt_more'); } add_action('after_setup_theme', 'change_excerpt_more'); |
Save the file.
Recommended Posts :Twenty Thirteen WordPress Theme Customization
How To Create WordPress Twenty Thirteen Child Theme
Again open content.php file around Line No 34 you can see
1 |
<div class="entry-summary"> |
Below this line add the following code
1 2 3 4 5 6 |
<!-- Adds the 140x140 thumbnail (featured image) --> <div class="excerpt-thumb"> <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentythirteen' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"> <?php the_post_thumbnail('excerpt-thumbnail', 'class=alignleft'); ?> </a> </div> |
This code adds the featured image to the post Excerpts with left alignment.
Around line no 15 in content.php file you can see the following line
1 |
<?php the_post_thumbnail(); ?> |
Remove the line and save the file.
Now you can see the Thumbnail (featured image) and Read More link in the Excerpts posts.
Post Excerpts Preview
Download the modified code of content.php and function.php for your reference.
[wpdm_file id=2]Hope this tutorial was helpful to you and if you have Questions let us know through comments.
Thanks for this tutorial. I’ve used it.
I really found the solution for My problem. thanks!
Working with simpleX ! its fine, congratulations