Show Beginning of post in home page with read more button.


As you see in the snapshot above, there are few lines of a post displayed with a read more button. You can achieve identical results using php like this-


//This is just a loop if you need to use it for more than one post
<?php foreach($content as $c) 

//This is the main thing you will have to do, here i am truncating post to 500 letters
$displayText = substr($c['content'], 0, strrpos(substr($c['content'], 0, 500), ' '));

// Displaying the truncated post
echo $displayText;?>

//This is for making read more button, you will have to put your complete post's link here
 read more
<?php endforeach; ?>

This will give you an idea on how it is done, you can use the code for truncating with your post and if you have any problems feel free to comment or contact me.

Comments