Change more-link display text in WordPress

For a recent project we created an online house pricer for the Dutch market, Huizen Prijs Checker. The backend, a statistical model, was built using Java which connects to our PHP / WordPress frontend using an API. We have worked with WordPress before, but once again we were surprised to see how easy it’s to setup and customise using templates and plug-ins.

The site being local to Dutch market is all in Dutch. This meant creating pages and blogs in Dutch. Which works wonderfully. The one thing which gave us headache was the continue reading text displayed by the more-link object.  The tag is inserted using the WordPress editor as shown here:

read more insert

On your blog-role or category pages a link will be displayed with the text “Continue reading ->”, like so:continue

This wasn’t any good as our site was meant to be in Dutch. So we where hoping for something like:

lees meer

It took quite some time to figure out how to get our theme to display a “continue reading” link with custom text. As it turns out this can be fixed by creating a child package. Details on how to do this can be found in WordPress Codex. Once you have the child theme setup the link text can be modified by adding a new read_more_link function to the functions.php file in your theme. This function will then override the default behaviour of the links. The following snippet does the trick.

<?php

/**

* Enqueues child theme stylesheet, loading first the parent theme stylesheet.

*/

function themify_custom_enqueue_child_theme_styles() {

wp_enqueue_style( 'parent-theme-css', get_template_directory_uri() . '/style.css' );

}

add_action( 'wp_enqueue_scripts', 'themify_custom_enqueue_child_theme_styles' );

function modify_read_more_link() {

return '<a class="more-link" href="' . get_permalink() . '">Lees meer  &raquo;</a>';

}

add_filter( 'the_content_more_link', 'modify_read_more_link' );

If you are also using excerpt_more links there is a another function that needs to be overridden. The excerpt links can be displayed directly on your site or by some of the plugins you use. In our case they were used in the top banner of the site.

exceprt demo

To customise both links types we used the snippet below to update our functions.php in the child theme.

<?php

/**

* Enqueues child theme stylesheet, loading first the parent theme stylesheet.

*/

function themify_custom_enqueue_child_theme_styles() {

wp_enqueue_style( 'parent-theme-css', get_template_directory_uri() . '/style.css' );

}

add_action( 'wp_enqueue_scripts', 'themify_custom_enqueue_child_theme_styles' );

function new_excerpt_more($more) {

   global $post;

   return '... <a href="'. get_permalink($post->ID) . '">' . 'Lees meer &raquo;' . '</a>';

}

function modify_read_more_link() {

return '<a class="more-link" href="' . get_permalink() . '">Lees meer &raquo;</a>';

}

add_filter('excerpt_more', 'new_excerpt_more', 20);

add_filter( 'the_content_more_link', 'modify_read_more_link' );

We hope this blog will save you some time figure out how to get WordPress to play nice in other languages.

2 thoughts on “Change more-link display text in WordPress

Leave a Reply

Your email address will not be published. Required fields are marked *