Home » Webtips » PHP Function to limit content with complete word
Webtips

PHP Function to limit content with complete word

The following function can be used to limit the content with a complete word rather than broken words.

In wordPress paste the above function in the function.php file in the theme folder. After that call the function from the template file or any other file where you want to limit the content by

Now $limited_content contains limited content.
In the function, first parameter, ‘$content’ is the actual content which wants to be limited.
Second parameter is the limit count. ie characters to be limited.
Third parameter is the string/character to be appended at the end of the limited text. here it is ‘…’.

About the author

Vipin

Hi, i am Vipin, a programmer working in Dubai, UAE. I love blogging, and so started TechRounder for sharing my findings and other digital informations with others too. Please feel free to share your feedback with me in the comment section below or you can email me at vipin@techrounder.com.

Add Comment

Click here to post a comment

Your email address will not be published. Required fields are marked *

Get latest updates
in your inbox

Subscribe to TechRounder mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.