Read More… Style Links and Limiting Character Length

I find myself in an interesting scenario, and now i get to sit here and do some solid coding to get this looking a little more “blog like” and a little less “Work in progress” like.

The first thing I noticed this morning after posting all the back dated post’s is that if a post is more than about 200 characters long, then the mouse over disappears above the screen. So I have to implement some character length restrictions.

It was pretty simple actually, but I think i will do some more work on it soon to include a “read more” style link to it.

// custom character limit - Edit this as you wish
$limit = 200;

// preset $post value Demo purposes only
$post = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed fermentum";

if (strlen($post) > $limit) {
	$post = substr($post, 0, strrpos(substr($post, 0, $limit), ' ')) . ' Read More...';

Leave a Reply