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

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

When writing out the category description in my theme (on archives and special category listings) for example, there are times I need the description in full html mode and others when I need it returned stripped of any html.

In the code below, I actually need the stripped version of the description, however $category->description returns the full description with all tags, which is rendering my strlen snippet function inoperable depending on where it breaks.

How can I obtain an html stripped version of the description in the loop below?

foreach($categories as $category) {
    echo '<li style="clear:both;">'.get_category_thumbnail($category->term_id, 'thumbnail').'<a style="display:block;margin-top:20px;" href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a>';

        if(strlen($category->description) > 300 ) echo SUBSTR( $category->description,0,STRPOS( $category->description,".",300)+1);
        else echo  $category->description;
share|improve this question
up vote 1 down vote accepted

Have you tried something like this?


Here the reference page for the strip_tags function

share|improve this answer
Yep, that's it. Thanks Paul! – Scott B Jan 8 '11 at 16:09

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.