Created
March 31, 2016 14:25
-
-
Save carasmo/1d18cc93d8e82a8fd9e30477b93d68b1 to your computer and use it in GitHub Desktop.
Read More outside the paragraph
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//don't include this | |
/** ==================================================================================== | |
* Break more link outside the paragraph in the loop on all archives (home, archives, search, etc) | |
==================================================================================== **/ | |
function yourprefix_excerpt_more_link() { | |
// Remove More Link from get_the_excerpt() | |
function more_link() { | |
return ''; | |
} | |
add_filter('excerpt_more', 'more_link'); | |
//New excerpt | |
function get_read_more_link() { | |
$excerpt = get_the_excerpt(); | |
return '<p>' . $excerpt . ' ... </p> <p class="your-class-goes-here"><a href="' . get_permalink() . '">Read More</a></p>'; | |
} | |
add_filter( 'the_excerpt', 'get_read_more_link' ); | |
} | |
add_action( 'after_setup_theme', 'yourprefix_excerpt_more_link' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment