37 | Custom ‘Read More’ text per Post for Twenty Ten

g+

A sophisticated way to get a custom written ‘read more’ text added to your posts in the theme Twenty Ten (or its child themes).

The code builds on this article I posted earlier.

It uses the custom field with the key ‘cont_read’ to hold the custom text.

Add this code to functions.php of the theme:

/* 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>&rarr;</span>' ) {
 return $translations->translate( $cont_read . ' <span>&raquo;</span>' );
 }
 return $translation; // custom field value
 else :
 return $translation; // standard text
 endif;
 }
}
add_filter('gettext', array('Transformation_Text_Wrangler', 'reading_more'), 10, 4);
This entry was posted in WordPress and tagged , , , , . Bookmark the permalink.

4 Responses to Custom ‘Read More’ text per Post for Twenty Ten

  1. Ben comments:

    Just want to let you know, you really helped me with help you provided here:

    http://wordpress.org/support/topic/images-wont-show-in-post?replies=3

    Since I am not super rich, I will click the adds on this blog from time to time.

    Cheers (:

    • alchymyth replies:

      Thank you for your comment and your intentions.
      All help given in the wordpress support forum is given freely. Therefore, I do recommend only to click the adverts if you are genuinely interested in the services they offer.

      cheers

  2. Andrew comments:

    Thanks for that.Problem is..I don’t have a clue what it all means.All I want to do is be able to view any of the other jpeg header picsin the themes/twentyten file and be able to change the present header pic.I’m not good at technical stuff so I need simple instructions in a step by step way please..i.e.Step 1,Step 2 etc.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*