Created
August 28, 2013 21:03
-
-
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.
This file contains hidden or 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 | |
//* 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