WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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.