Get the <!–more–> link text

How I can get the link text is using WordPress?

By default is something like:

Read More
Read More <span class="meta-nav">→</span>

buy I want to get that value in a variable because some WordPress installation can have that value customized (using filter the_content_more_link) or in another language.

In resumen: what I need is to get from WordPress the text (the HTML code) that WordPress uses to replace the when display a Post Content.

Related posts

Leave a Reply

1 comment

  1. You can use posts custom fields to store a custom continue reading text for each post, and then use that value in the_content_more_link filter. For example you might have a custom field with meta key of continue_reading to enable users to specify the custom Read More text, and use that value like:

    add_filter('the_content_more_link', 'ad_contiue_reading_text',10,2);
    function ad_contiue_reading_text($content_more_link, $read_more_text) {
    
        $post = get_post();
        $new_read_more_text = get_post_meta($post->ID, 'continue_reading', true);
        // .. or any text you want, for example:
        // $new_read_more_text = 'Discover More <span>&rarr;</span>';
    
        if($new_read_more_text) {
            $content_more_link = str_replace($read_more_text, $new_read_more_text, $content_more_link);
        }
    
        return $content_more_link;
    }