Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am trying to print the post excerpt using the following code:

<?php echo $post->post_excerpt;  ?> 

It works fantastic the only problem is that apparently I get also predefined styles and I cannot get rid of them. How can I get the raw text - is there a different function or maybe there is a php function that returns text only?

share|improve this question

2 Answers 2

up vote 0 down vote accepted

Using the PHP strip_tags() function should clean out the unwanted HTML elements.

echo strip_tags( $post->post_excerpt );
share|improve this answer

Using the WorPress wp_strip_all_tags() function you can properly strip all HTML tags including script and style.

echo wp_strip_all_tags( $post->post_excerpt );


1).wp_strip_all_tags fx properly strip all HTML tags including script and style.while strip_tags strip HTML and PHP tags from a string only.

2).pass second parameter true if you want to remove break tag <br/> also.

   echo wp_strip_all_tags( $post->post_excerpt, true );
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.