WordPress.org

Ready to get started?Download WordPress

Forums

How to put ads next to content (3 posts)

  1. klippert
    Member
    Posted 1 year ago #

    Hi I want to know how to put my adsense ads beside content. I know i can use

    <?php
    
    $paragraphAfter= 0; //display after the first paragraph
    
    $content = apply_filters('the_content', get_the_content());
    
    $content = explode("</p>", $content);
    
    for ($i = 0; $i <count($content); $i++ ) {
    
    if ($i == $paragraphAfter) { ?>
    
    <div><script type="text/javascript"><!--
    google_ad_client = "ca-pub-1899371351571952";
    /* Content head */
    google_ad_slot = "2921193851";
    google_ad_width = 336;
    google_ad_height = 280;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script></div>
    
    <?php }
    
    echo $content[$i] . "</p>";
    
    } ?>

    [Please post code or markup snippets between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

    to make ads appear through out it but it does not make it look like it is part of the content like i want it to. it just makes a blank block and inserts the ad there. i want to make the ad flow into the content like a picture would, beside my content

  2. Install WP
    Member
    Posted 1 year ago #

    Using div styling usually works fine, try this

    <div style="margin: 0px 10px 0px 5px; display: block; float: left;">
    ADSENSE CODE HERE
    </div>

  3. klippert
    Member
    Posted 1 year ago #

    Where would I put that in the wp code

Topic Closed

This topic has been closed to new replies.

About this Topic