Last active
October 30, 2018 14:39
-
-
Save nfsarmento/348274efab13e5aa1f9d0fecb567c9b4 to your computer and use it in GitHub Desktop.
"Read more" link to post excerpts of custom post types
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
/** | |
* Adds a custom "Read more" link to post excerpts of custom post types. | |
* Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and "Read more". | |
* | |
* https://www.nuno-sarmento.com | |
*/ | |
function ns_cpt_excerpt_more( $more ) { | |
global $post; | |
$anchor_text = 'Read more'; | |
if ( 'YOUR_CUSTOM_POST_TYPE_NAME' == $post->post_type ) { | |
$more = ' … <a href="'. esc_url( get_permalink() ) . '">' . $anchor_text . '</a>'; | |
} | |
return $more; | |
} | |
add_filter('excerpt_more', 'ns_cpt_excerpt_more'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment