A Simple Guide to Extract Excerpt from WordPress Post Content – WordPress Tutorial

By | August 1, 2019

When you are writing article using wordpress, you can add an excerpt content for your post. However, if you do not add, we will introduce you to extract excerpt from post content in this tutorial.

wordpress excerpt examples and tutorials

1.Get wordpress post content

get_the_content()

2.Extract excerpt with length limitation

For example, you only want to show 100 words in excerpt at most.

 <?php
 $words = explode(" ",strip_tags(get_the_content()));
 $content = implode(" ",array_splice($words,0,100));
 echo $content;
 ?>

Then the $content is excerpt.

Leave a Reply

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