Changing the ‘Read more’ in Twenty Ten Child Theme

To change the ‘read more’ text in a child theme of Twenty Ten, one needs to add a few lines to functions.php of the child theme.

This procedure uses a method that I came across in an introductory article about programming a child theme of Twenty Ten, by Aaron Jorbin, who himself was building upon Mangling strings for fun and profit, by WordPress lead Developer Peter Westwood.

class Transformation_Text_Wrangler {
function reading_more($translation, $text, $domain) {
$translations = &get_translations_for_domain( $domain );
if ( $text == 'Continue reading <span class="meta-nav">&rarr;</span>' ) {
return $translations->translate( 'Get to know more <span class="meta-nav">&raquo;</span>' );
}
return $translation;
}
}
add_filter('gettext', array('Transformation_Text_Wrangler', 'reading_more'), 10, 4);

This way of customising texts in a child theme is applicable to all the strings of the mother theme.

17 Replies to “Changing the ‘Read more’ in Twenty Ten Child Theme”

  1. のびのびスムージーの品質は詳細に管理されているので、生産国も安心の日本です。のびのびスムージーを飲み始めるのは、いつからでも大丈夫です。小学校1~2年生から始められる方が多いですが、高学年から始めても全然遅くはありません。成長期には個人差があり、小学校の高学年がピークになる子もいれば、中学2年生から一気に身長が伸びる子もいます。やはり健康的に育って行くには、コツコツと必要な栄養をしっかりと摂る必要があり、少しだけ栄養を摂ってもあまり意味はないです。お子さんに毎日健康的に育っていって欲しいと考えるなら、早いうちにスタートして長く継続するのが大切だとと言えるでしょう。

  2. I am a total newbie and I am trying to have a read more on a page, have done masses of reading but not finding anything. Found code in the codex page but do not know which file to put it in. I am using the twenty ten template and tried, index.php, page.php and others to no avail.

    When I used the read more on the page, it seems to ignore the tag and displays the whole page. Could anyone help me figure this out as this is my very first try and I have spent days and got nowhere.

    This is the code I found but I don’t know wher to put it //

    //

    I really have no idea how to make a child theme so was trying to put it in the theme? Any help would be appreciated.

    1. try to check loop.php and loop-page.php in Twenty Ten. what kind of page are you talking about? a static page. or a archive page? ‘read-more’ and static pages don’t really work together.
      to ask all your wordpress related questions, consider joining the wordpress.org support forum – there are many members who should be able to help you with your problems.

  3. Thanks for this – I spent a day and tried a dozen ideas from Google before I found one that actually works!
    Many thanks!

  4. Hi, how we can styling this function? For example, button background for “Get to know more”, etc etc, or just a different font, etc.

  5. Does this also change the “…” before the text of the read more? I’m using this in my child theme as I couldn’t find a way to remove the 3 periods before the text.
    // remove the ... from excerpt and change the text
    function change_excerpt_more()
    {
    function new_excerpt_more($more)
    {
    return '<span class="read-more"><a href="' . get_permalink($post->ID) . '">Read the Rest &raquo;</a></span>';
    }
    add_filter('excerpt_more', 'new_excerpt_more');
    }
    add_action('after_setup_theme', 'change_excerpt_more');

  6. What about if you wanted to have the post title displayed as the link – as in Continue Reading (post title)

      1. Thanks for the reference, that seems to be the pre WP 3 way to do it, and the way I had it set up previously. But when I updated to WP 3 it no longer worked. I did finally track it down – the file to edit is loop.php (preferably in a child theme so you don’t lose the change on updates).

        <?php the_content( __( 'Continue reading <span class="meta-nav">&raquo; </span>' . get_the_title('', '', false), 'twentyten' ) ); ?>

        That seemed to do the trick – it seems to override your suggested method of changing the “continue reading” text however. But the text can be changed directly in that statement to whatever you’d like without the need to add to the functions.php file.

  7. Thanks, this is great! Question, though.
    I seem to be breaking this with the text I want to place in there. I’d like to add “But wait, there’s more”, but the apostrophe seems to be breaking it. Is there a way have it in there?

  8. Thank you so much for this!
    I have been trying for many hours now to make this happen, and compared with everything else I’ve modified in WP, this has been the hardest solution to track down…
    You are a star :o)

Leave a Reply to Greg Astles Cancel reply

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