Get a limited, character (text) from a wordpress post

There are two way to get limited character

1. First way

<?php wp_trim_words( $text, $num_words = 55, $more = null ); ?>

The parameter break down:

(string) (required) Text to trim
Default: None

(integer) (optional) Number of words
Default: 55

(string) (optional) What to append if $text needs to be trimmed.
Default: '…'

2. Second Way

In function we can get post content without image

$content = get_the_content();
echo substr($content, 0, 25);

Leave a Reply