
Image Credit: Work Less, Read More
I guess I’ve been doing a lot of work lately on being able to do blog posts by email. When combined with a useful Markdown WordPress plugin, it really expands your ability to get stuff written and I’m loving it.
Never content to leave things be, I decided to add some additional functionality to the Postie plugin: namely, customizing the Read More link text for Thesis theme.
A nice feature of Thesis (and other theme frameworks) is the customizability. When I was adding some custom Thesis post image support for Postie in my other article, I decided it wouldn’t be much more work to add a way to set the text used when you specify your <!–More–> tag text. This allows you to make a more interesting link than just “Read More…”.
If you are interested in doing this, then read on…
Our tutorial begins by adding a simple function to the postie-functions.php file. You can edit this right from your WordPress Admin interface if you’re feeling brave, or working on a test file might be more wise. Your choice.
Add a New Function
We want the parser to scan the post content and remove the customized more link and its value, like it does for the tags function called postie_get_tags(). Except this is even simpler.
Paste in the following function anywhere into your file:
/**
* this function captures the user-specified more text for use with Thesis
*
*/
function postie_more_text(&$content, $default_text="Read More...") {
$more_text = $default_text;
//try and extract a value
if ( preg_match('/moretext: ?(.*)\n/i', $content, $matches)) {
$content = str_replace($matches[0], "", $content);
$more_text = $matches[1];
}
return($more_text);
}
Modify the Existing Post Array
Next we need to add support for the object that gets passed around and filtered.
Line 176:
Add an additional entry to the end of the array, don’t forget to add a comma to the previous line.
'more_text' => $more_text
Call the Code
After the call to postie_get_tags on Line 106 insert the following line to call our function:
$more_text = postie_more_text($content);
Add (yet another) Postie Filter
If you followed my previous article, you already have a Postie filter that will add Custom fields for the Thesis post image. If not, go check out the article.
Add the following line to your filter function:
add_post_meta($post['ID'], 'thesis_readmore', $post['more_text']);
Add moretext to Your Posts
Now anytime you send a post you can specify a line like:
moretext: Read My Brilliant Article
Remember, it needs to be on its own line, like the tags.
And you’ll find that this value is now added as a custom field in your post. You’ll need to include the More link in your post to activate it, but you can insert that into any post by email since it handles inline HTML just fine.
Give it a whirl and let me know how it works for you.
Oh, and start writing more!
