WordPress.org

Ready to get started?Download WordPress

Forums

Strip HTML Tags but Keep adsense/ infolinks /other scripts (5 posts)

  1. muqeetsoomro
    Member
    Posted 2 years ago #

    Hi!
    I had worst complains but HTML which run in my posts and damage the template of blog. I search about to strip HTML tags I got following code
    that put in single.php of theme.

    <?php
    ob_start();
     the_content(''.__('Read more <span class="meta-nav">ยป</span>', 'sandbox').'');
    $old_content = ob_get_clean();
    $new_content = strip_tags($old_content, '<p><a><b><br /><input><form><img><textarea><li><ol><ul><table>');
    echo $new_content;
    ?>

    I get this code from http://wordpress.org/support/topic/way-to-strip-html-from-the_content-1?replies=6
    This work fine for me but remove ad sense / other scripts that are present in posts. I search about this but no clue find.
    please help me

  2. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    http://php.net/manual/en/function.strip-tags.php

    you possibly need to extend the exempted tags to include <script> and whatever tags are in the adsense/scripts

  3. muqeetsoomro
    Member
    Posted 2 years ago #

    I use "<script>" tag in allowed but adsense codes does not appear

  4. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    what is the output of the code?

    does the script code appear in the output?

    can you post a link to a post with the problem?

    can you paste the full code of single.php into a http://pastebin.com/ and post the link to it here? (see http://codex.wordpress.org/Forum_Welcome#Posting_Code )

  5. muqeetsoomro
    Member
    Posted 2 years ago #

    pastebin http://pastebin.com/zSfBZPsE
    ads in post don't appear... that is output by using <script>

    Again I repeat my Question How I can allow the scripts tag above code

Topic Closed

This topic has been closed to new replies.

About this Topic