Created
November 30, 2016 22:45
-
-
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
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
/** | |
* 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 ); |
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
// 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