Skip to content

Instantly share code, notes, and snippets.

@dkmy-sec
Created November 30, 2016 22:45
Show Gist options
  • Save dkmy-sec/bb1a34a9b56f8f15be5416ece0c894ae to your computer and use it in GitHub Desktop.
Save dkmy-sec/bb1a34a9b56f8f15be5416ece0c894ae to your computer and use it in GitHub Desktop.
WP Function Replaces the Read More with ellipses & Limits Excerpt character count
/**
* Filter the except length to x characters.
*
* @param int $length Excerpt length.
* @return int (Maybe) modified excerpt length.
*/
function wpdocs_custom_excerpt_length( $length ) {
return x;
}
add_filter( 'excerpt_length', 'wpdocs_custom_excerpt_length', 999 );
// Replaces the excerpt "Read More" text by a link
function new_excerpt_more($more) {
global $post;
return '<a class="moretag" href="'. get_permalink($post->ID) . '">...</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment