Display First Few Characters Of A WordPress Post Outside The Loop

[ad_1]

<?php echo apply_filters( 'the_content', wp_trim_words( strip_tags( get_post_field('post_content', $recent["ID"]) ), 55 ) ); ?>

where
$recent["ID"]
is of the ID of the post.

If you are already querying the post and already have a WP_Post object, you can simply use this:

<?php echo apply_filters( 'the_content', wp_trim_words( strip_tags( $recent["post_content"] ), 55 ) ); ?>

For an example, see this: Query Anything On WordPress Anywhere

[ad_2]

Leave a Reply

Random Post Selection ::

Recent Posts

Unlock Unlimited Downloads