• Resolved billbennett

    (@billbennett)


    I’ve been looking at customising the ‘continue reading’ link in a Twentyten child theme – I managed to change the ‘read more’ link in an earlier theme, but it looks far more complex in Twentyten. Has anyone found out how to do this?

Viewing 15 replies - 1 through 15 (of 25 total)
  • Look at the function.php file, line 241. The wording can be changed there.

    Far better to put the new function when u find it in functions.php in yr Child Theme IMHO. Never hack core files.

    Here u go

    // no more jumping for read more link
    function no_more_jumping($post) {
    	return '<a href="'.get_permalink($post->ID).'" class="read-more">'.'Continue Reading'.'</a>';
    }
    add_filter('excerpt_more', 'no_more_jumping');
    Thread Starter billbennett

    (@billbennett)

    Thanks. I should have been clearer. In my old theme I used custom fields to give each post a different ‘read more’.

    This looks so much harder in Twentyten.

    The Twenty ten theme is far more complex, but making child themes is much easier. As pointed out by Root, you could make a child theme with the new function, but I have no idea how to modify the function to read something different for each post…. sorry.

    Well there must be a function to do that somewhere……Looking at the function I posted you just need to add an array and rotate thru it ??

    /* Twenty Ten custom 'continue reading'
    /
    / custom field ($key = 'cont_read' ) dependant 'continue reading' text
    / alchymyth 2010
    */
    class Transformation_Text_Wrangler {
    function reading_more($translation, $text, $domain) {
    
    global $post;
      $cont_read = get_post_meta( $post->ID, 'cont_read', true );
      if( $cont_read ) :
        $cont_read = htmlentities($cont_read, ENT_QUOTES);
        $translations = &get_translations_for_domain( $domain );
        if ( $text == 'Continue reading <span class="meta-nav">&rarr;</span>' ) {
           return $translations->translate( $cont_read . ' <span class="meta-nav">&raquo;</span>' );
            }
        return $translation; // custom field value
      else :
        return $translation; // standard text
      endif;
     }
    }
    add_filter('gettext', array('Transformation_Text_Wrangler', 'reading_more'), 10, 4);

    extended, from:
    https://www.transformationpowertools.com/wordpress/read-more-in-twenty-ten-child-theme

    Very cool. Thanks ??

    Thread Starter billbennett

    (@billbennett)

    Would it be possible to pull the text for alternatives to “Continue reading” from a custom field?

    that is exactly what the snippet posted earlier does:

    here is the line referring to the custom field:

    $cont_read = get_post_meta( $post->ID, 'cont_read', true );

    Thread Starter billbennett

    (@billbennett)

    I’m sorry – I tried reading the code, but couldn’t figure it out. (I’m not really a programmer at all).

    no problem –
    it should work if you make a custom field with the key ‘cont_read’ and then enter your chosen text, what you would like to see instead of the ‘continue reading’.

    the code also changes the arrow → &rarr; into »
    &raquo;

    did you get it to work?

    Thread Starter billbennett

    (@billbennett)

    I’ve loaded the function into my child theme without a problem, but don’t have it working properly yet. Will spend the later part of today trying to figure out why ??

    Thread Starter billbennett

    (@billbennett)

    It’s hard to see why this isn’t working.

    I’ve added the code to functions.php which is in the child theme directory.

    If I add a custom field entry it flashes yellow – which is a good sign.

    But continue reading doesn’t change on the home page or on the archive pages.

    do you save/update the custom field?
    do you update/save the post?

    is the custom field content still there if you go back and edit the post?

Viewing 15 replies - 1 through 15 (of 25 total)
  • The topic ‘Custom "continue reading" in Twentyten’ is closed to new replies.