Skip to content

Instantly share code, notes, and snippets.

@davidvandenbor
Last active July 15, 2016 00:04
Show Gist options
  • Save davidvandenbor/a90c776e14e50f60db8e3f62c9c879b3 to your computer and use it in GitHub Desktop.
Save davidvandenbor/a90c776e14e50f60db8e3f62c9c879b3 to your computer and use it in GitHub Desktop.
WP custom excerpt lenght for global use
<?php
/**
* @author @david
* Wordpress excerpt lenght for global use, with automatic "read more"
*
*/
function et_excerpt_length($length) {
return 120;
}
add_filter('excerpt_length', 'et_excerpt_length');
/* Add a link to the end of our excerpt contained in a div for styling purposes and to break to a new line on the page.*/
function et_excerpt_more($more) {
global $post;
return '<div class="text-right"><a href="'. get_permalink($post->ID) . '" class="button small">Lees verder</a></div>';
}
add_filter('excerpt_more', 'et_excerpt_more');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment