Support » Fixing WordPress » html and google ads problem

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

    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?

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.

    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.

    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.