Skip to content

Instantly share code, notes, and snippets.

@AMNDesign
Created August 28, 2013 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AMNDesign/6371251 to your computer and use it in GitHub Desktop.
Save AMNDesign/6371251 to your computer and use it in GitHub Desktop.
Add a "read more" link after both manual excerpts and regular excerpts and customize the link text for custom post types in WordPress.
<?php
//* Add read more link after both manual excerpts and regular excerpts and customize link text for custom post types
add_filter('the_excerpt', 'amn_manual_excerpt_read_more_link');
function amn_manual_excerpt_read_more_link($output) {
global $post;
if ( get_post_type() == 'my_custom_post_type_slug' ) {
$link_text = 'My CPT Read More Text';
} else {
$link_text = 'Read More';
}
return substr($output,0,-5).'... <a href="' . get_permalink($post->ID) . '">' . $link_text . '</a>.</p>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment