[resolved] html and google ads problem (3 posts)

  1. MyDaily-Gadget
    Posted 5 years ago #

    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):

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


    I end up with this code, transformed:

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

  2. Michael
    Part-Time Forum Moderator
    Posted 5 years ago #

    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.


    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 type="text/javascript"
    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.

  3. MyDaily-Gadget
    Posted 5 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic