Last active
June 6, 2023 18:22
-
-
Save carasmo/0a5070299c2d89ab02c3 to your computer and use it in GitHub Desktop.
Force the read more link on excerpts even if the content is below the threshold and even if it's a custom excerpt.
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 | |
/** ==================================================================================== | |
* Force read more link to all excerpts whether or not it meets the word length criteria | |
* and whether or not it is a custom excerpt | |
==================================================================================== **/ | |
function excerpt_more_link_all_the_time() { | |
// Remove More Link from get_the_excerpt() | |
function more_link() { | |
return ''; | |
} | |
add_filter('excerpt_more', 'more_link'); | |
//Force read more link on all excerpts | |
function get_read_more_link() { | |
$excerpt = get_the_excerpt(); | |
return '<p>' . $excerpt . ' ... <a href="' . get_permalink() . '">Read More</a></p>'; | |
} | |
add_filter( 'the_excerpt', 'get_read_more_link' ); | |
} | |
add_action( 'after_setup_theme', 'excerpt_more_link_all_the_time' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment