In this tutorial, I will show you how to replace “Read more” text with your custom text of your choice in GeneratePress Free Theme.
In the below PHP Code Snippet, I have replaced “Read more” text with “Download”.
Follow below steps to add custom PHP code to your website –
- Access your backend dashboard
- Go to Plugins > Add New
- Search for “Code Snippets” plugin in the search box
- Install and Activate the plugin
- Now go to Code Snippets and Click on Add New
- Add a Snippet Title
- Copy and Paste the below PHP code snippet
- Hit “Save Changes and Activate” Button.
PHP Code Snippet
add_filter( 'wp_trim_excerpt', 'tu_excerpt_metabox_more' );
function tu_excerpt_metabox_more( $excerpt ) {
$new_excerpt = str_replace("Read more</a>","Download",$excerpt);
$output = $new_excerpt;
if ( has_excerpt() ) {
$output = sprintf( '%1$s <a href="%2$s">%3$s</a>',
$excerpt,
get_permalink(),
__( 'Download', 'generatepress' )
);
}
return $output;
}
In the above snippet you have to replace the text “Download” with your own text.