Skip to content

Early-bird lifetime licence: $199 once, for the first 200 buyers only. See the offer

excerpt_more

Changes the text added to the end of a shortened automatic excerpt. By default it's ' […]'.

  • Type Filter
  • From WordPress
  • Since 2.9.0
  • Fired in wp-includes/formatting.php

When it fires

WordPress applies excerpt_more in wp_trim_excerpt() when it builds an automatic excerpt from a post's content. What you return is added to the end of the text, but only if the text was actually cut short.

It isn't used for manual excerpts typed into the Excerpt box.

Parameters

Parameters
$more_stringstring The string shown within the more link.

What to return

The string to add after the excerpt. It can contain HTML, so escape anything you add.

Example: Replace […] with a Read more link

PHP
add_filter( 'excerpt_more', function () {
	return sprintf(
		'… <a class="read-more" href="%1$s">%2$s</a>',
		esc_url( get_permalink() ),
		esc_html__( 'Read more', 'my-snippets' )
	);
} );

Good to know

  • In block themes, if the Post Excerpt block has its own 'more' text set, the block replaces your output with nothing, so only one link shows.
  • get_permalink() without an argument uses the current post, so this is meant for excerpts shown in the loop.

Move your snippets over this afternoon.

Importing changes nothing until you switch over, and your old shortcodes keep working.