• Hi,

    After digging around these forums, I found a simple bit of PHP to strip the tags out of a post:

    <?php
                        ob_start();
                        the_content();
                        $old_content = ob_get_clean();
                        $new_content = strip_tags($old_content);
                        echo $new_content;
                        ?>

    This works great, and outputs the entire post without tags. However, I’m trying to restrict the number of characters that are output to 200. Is this possible? Any help would be greatly appreciated.

    Thanks!

    Jamie

Viewing 1 replies (of 1 total)
  • It sure is possible, and pretty easy.

    <?php
        ob_start();
        the_content();
        $old_content = ob_get_clean();
        $new_content = strip_tags($old_content);
        $new_content = substr ($new_content, 0, 200);
        echo $new_content;
    ?>

    That will get everything up to 200 characters long. If the string is less then 200 it will just return everything.

Viewing 1 replies (of 1 total)
  • The topic ‘Limit Characters, after stripping tags?’ is closed to new replies.