• Resolved mydaily-gadget

    (@mydaily-gadget)


    I know this is not quite the area of this forum, but maybe you guys have an idea.

    My problem looks like this ( the // lines before my excerpt):
    Link1

    I have that Google ads are causing this problem, because when i insert this code into the HTML section of my post:

    Link2

    I end up with this code, transformed:

    Link3.
    And those marked // are visible to the front page.Any idea guys?

Viewing 2 replies - 1 through 2 (of 2 total)
  • i am quite sure that you can’t add javascript directly into the html editor of a post.

    to add google ads into a post or page, you could use shortcodes.

    https://codex.www.ads-software.com/Shortcode_API

    in functions.php of the theme, add:

    // [adsense]
    function add_adsense($atts) {
    
    return '<span class="adsense">
    <script type="text/javascript"><!--
    google_ad_client = "pub-0123412341234123";
    /* your google ads */
    google_ad_slot = "1234512345";
    google_ad_width = 468;
    google_ad_height = 60;
    //-->
    </script>
    <script type="text/javascript"
    src="https://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
    </span>';
    }
    
    add_shortcode('adsense', 'add_adsense');

    substitute your own google code.
    the span with the class .adsense is optional to style the ads (for instance use float:left; with some margins to let the text float around the ads);
    place them whereever you want in a post or page by typing [adsense] into the text.

    you might also be able to find a plugin to deal with adsense.

    Thread Starter mydaily-gadget

    (@mydaily-gadget)

    thank you:) i edited the code above and it worked. Thanks a lot.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘html and google ads problem’ is closed to new replies.