Post

WordPress Posts Custom Excerpt

Add snippets to your functions.php

Custom Excerpt Length

Change the length

1
2
3
4
  function custom_excerpt_length( $length ) {
	      return 20;
	}
	add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

Custom Excerpt More

Change the excerpt display link based on what post type is being viewed

1
2
3
4
5
6
7
8
function new_excerpt_more( $more ) {
    if ('testimonials' == get_post_type()) {
          return ' <br /><a class = "more" href="'. get_permalink(isset($post->ID)) . '"> View</a>';
    } else {
          return ' <br /><a class = "more" href="'. get_permalink(isset($post->ID)) . '"> Read More</a>';
    }
}
add_filter('excerpt_more', 'new_excerpt_more');

custom excerpt link text

This post is licensed under CC BY 4.0 by the author.