read_more_large

To customise the link to the post from the excerpt you will need to make a function and then hook it to ‘the_excerpt’ filter tag.

The function:

function ML_excerpt_read_more_link($output) {
global $post;
return $output . '<a href="'. get_permalink($post->ID) . '" title="'. get_the_title().'"><i class="fa fa-book"></i> '. __( 'read more..','ML' ) .' </a>';
}

The $output variable which is returned contains the information which will be displayed as the ‘read more..’ part of the excerpt.
I have added a book icon before the text in the above example.

In the below example I’ve taken out the text and icon and replaced it with a smaller version of the featured image on this page.

function ML_excerpt_read_more_link($output) {
global $post;
return $output . '<a href="'. get_permalink($post->ID) . '" title="'. get_the_title().'"><img src="' .get_template_directory_uri() . '/images/read_more.png" alt="read_more" /></a>';
}

The hook:

add_filter('the_excerpt', 'ML_excerpt_read_more_link');

The hook can be written directly above or below the function.

Include the code anywhere in your functions.php file.

Previous

Next

No Comments

Leave a response