Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How I can get the link text is using WordPress?

By default is something like:

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.

share|improve this question

1 Answer 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;
}
share|improve this answer
    
Thanks, but what I need is to get from WordPress the text (or HTML piece) that WordPress uses to replace the <!--more--> when display a Post Content –  leticia Jan 26 '13 at 20:44
    
The text you want is passed as the second argument to the the_content_more_link filter (ie the $read_more_text in the above code) and there is no filter specific for that value. If you are developing a theme you can change that value by passing it directly to the_content($read_more_text), but if you are writing a plugin I think you need to use the the_content_more_link filter to manipulate it. –  Ahmad M Jan 26 '13 at 20:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.