Excerpts in Twenty Twelve Theme

Excerpts in Twenty Twelve Theme

In this post we will learn how to Excerpts in Twenty Twelve Theme. By following this approach excerpts will be shown instead of the full post.

Note: it’s a good idea to create a child theme when making modifications to the theme. How to Create a WordPress Child Theme.

1. Open Content.php and replace following line with new one:

<?php if ( is_search() ) : // Only display Excerpts for Search ?>

/**New one*/

<?php if ( is_search() || is_home() ) : // Display Excerpts for Search and Homepage ?>

2. Save and close Content.php and refresh Website. Now posts displayed as excerpts.

3. Open Functions.php, and paste below code after php opening tag.

add_image_size('excerpt-thumbnail', 200, 200, true);

4. Open Content.php and paste the below code after

<divclass="entry-summary">

<div class="excerpt-thumb">
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
<?php the_post_thumbnail('excerpt-thumbnail', 'class=alignleft'); ?>
</a>
</div>

5. Now remove following code from Content.php.

<?php the_post_thumbnail();?>

6. Open Functions.php and add below mentioned code, below the code which we added on step 3.

function change_excerpt_more()
{
function new_excerpt_more($more)
{
// Use .read-more to style the link

return '<div style="clear:both;padding-top:5px"><span class="continue-reading"> <a href="'. get_permalink($post->ID) . '"><img src="http://google.com/logo.png" alt="Read More"></a></span></div>';
}
add_filter('excerpt_more', 'new_excerpt_more');
}
add_action('after_setup_theme', 'change_excerpt_more');

One thought on “Excerpts in Twenty Twelve Theme

  1. Keith

    Because the admin of this web site is working, no question very soon it will be famous, due to its feature contents.

Comments are closed.