Now you can Subscribe using RSS

Submit your Email


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

Vishal Shrestha

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.

Vishal Shrestha / Author & Founder

A developer by profession, a born Adventurer. I mainly do Android but like to get my hands dirty with web development and a little bit of Python. I would't rather go on a Trek than a party and you can find me having a few rounds with the heavy bag to let out the steam ;)


Research and Development at : Ekghanti

Mobile Technology Lead at : Vimvox Lab

For Business info : My Portfolio Site


Post a Comment

Coprights @ 2017 | The Code City by Vishal Shrestha Vishal Shrestha