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.

Don’t miss these tips!

We don’t spam! Read our privacy policy for more info.

You’ve been successfully subscribed to our newsletter! See you on the other side!

Sharing is caring!

Leave a Comment

Your email address will not be published.

Exit mobile version