😂Excerpt full (ok)

https://wpshout.com/wordpress-post-excerpts/#gref

wp_trim_words

wp_trim_words(get_the_excerpt(), 15);

Hoặc

public function excerpt( $new_length = 15, $echo, $more_text = 'more') {
if(!is_admin()):
  add_filter( 'excerpt_more', $more_text, 999 );
  add_filter( 'excerpt_length', $new_length, 999 );
endif;
  if( $echo )
  the_excerpt();
  else
  return get_the_excerpt();
}

How to Change the Length of Your WordPress Excerpts with the excerpt_length Filter

function wpshout_longer_excerpts( $length ) {
	// Don't change anything inside /wp-admin/
	if ( is_admin() ) {
		return $length;
	}
	// Set excerpt length to 140 words
	return 140;
}
// "999" priority makes this run last of all the functions hooked to this filter, meaning it overrides them
add_filter( 'excerpt_length', 'wpshout_longer_excerpts', 999 );

How to Change the “Read More” Text of Your WordPress Excerpts with the excerpt_more Filter

How to Change the Text of a Post Excerpt with the get_the_excerpt Filter

How to Create One-Paragraph Excerpts with the wp_trim_excerpt Filter

How to Create Excerpts of a Specific Character Length (Rather than Word Length) with the wp_trim_excerpt Filter

How to Use wp_trim_words() to Get a WordPress Excerpt of Any Length from Arbitrary Text

Last updated

Was this helpful?