The excerpt_more WordPress PHP filter allows you to customize the “more” link displayed after a trimmed excerpt.
Usage
add_filter('excerpt_more', 'your_custom_excerpt_more'); function your_custom_excerpt_more($more_string) { // your custom code here return $more_string; }
Parameters
$more_string
(string): The string shown within the “more” link.
More information
See WordPress Developer Resources: excerpt_more
Examples
Change the default “more” string
Customize the “more” string to display “Read more” instead of the default “[…]”:
add_filter('excerpt_more', 'change_excerpt_more_string'); function change_excerpt_more_string($more_string) { return ' <a href="'. get_permalink() . '">Read more</a>'; } // Output: "Read more" link at the end of the excerpt
Add a “Continue Reading” button
Add a “Continue Reading” button after the excerpt:
add_filter('excerpt_more', 'add_continue_reading_button'); function add_continue_reading_button($more_string) { return ' <a href="'. get_permalink() . '" class="continue-reading-btn">Continue Reading</a>'; } // Output: "Continue Reading" button at the end of the excerpt
Show an arrow instead of text
Display a right arrow (→) instead of the default “[…]” or any text:
add_filter('excerpt_more', 'change_to_arrow'); function change_to_arrow($more_string) { return ' <a href="'. get_permalink() . '">→</a>'; } // Output: Right arrow link at the end of the excerpt
Remove the “more” link
Remove the “more” link completely from the excerpt:
add_filter('excerpt_more', 'remove_more_link'); function remove_more_link($more_string) { return ''; } // Output: No "more" link at the end of the excerpt
Add a custom CSS class to the “more” link
Add a custom CSS class to style the “more” link:
add_filter('excerpt_more', 'add_custom_css_class'); function add_custom_css_class($more_string) { return ' <a href="'. get_permalink() . '" class="custom-more-link">Read more</a>'; } // Output: "Read more" link with a custom CSS class at the end of the excerpt