Trim the word from the title or content in wordpress or php !

trim words in post and pages wordpress

Sometime we want to show only some words from the title or content of page/posts in wordpress.
In your php query you can trim title by using this function.

Here i trim the words of post title to show only first 3 words.. you can change as you need..instead of title you can apply this for post content too.

For Title
<?php echo wp_trim_words( get_the_title(), 3 ); ?>

 
For Content
<?php echo wp_trim_words( get_the_content(), 20 ); ?>

 

For any help contact me here

If this help you then.. Can you buy a Cup of Coffee for me by nst webcreation paypal--OR-- nst webcreation blog coffee cup

Published by

NST

Myself Narender Singh Thakur ( NST ) and i share my Experience/Knowledge and Tricks for folks and beginners to solve their issues while making websites through this Planet.

Related Articles

Leave a Reply

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

Click to Chat