• i would like to add adsense to my recent blog post automotically and align it to the left. so evrytime i post a new blog to my site, even though i dont put the adsense code i want automatic will show it to the left of the blog.

    and this is the code i would like to add

    <script type=”text/javascript”><!–
    google_ad_client = “pub-2657159394848468”;
    /* 300×250, created 10/5/08 */
    google_ad_slot = “6559489829”;
    google_ad_width = 300;
    google_ad_height = 250;
    //–>
    </script>
    <script type=”text/javascript”
    src=”https://pagead2.googlesyndication.com/pagead/show_ads.js”&gt;
    </script>

    and this is my website https://www.tunedtech.ca

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter tunedtech

    (@tunedtech)

    i read it and i found how i can add adsense to the first post but its asking me to look for this code to my index.php

    After the First Post
    Some advertising programs limit the number of ads per page, so you may need to only include ads after the first (or second or third) post. Here is an example:

    Edit index.php of your current theme.
    Look for: <?php if ($posts) : foreach ($posts as $post) : start_wp(); ?>This is called The Loop. Its purpose is to display posts. Just BEFORE that line, insert this code:
    <?php $postnum = 1; $showads = 1; ?>We’ve just created two variables, $postnum and $showads. The first will be incremented for every new post displayed. The second variable ($showads) is the number of posts you want to display before seeing ads. Next, find this code:
    <?php endforeach; else: ?>That line is the end of The Loop. Just BEFORE that line, add this:
    <?php if ($postnum == $showads) { ?> <<ADD ADVERTISING HERE>> <?php } $postnum++; ?>Make the appropriate changes such as inserting the advertiser’s code where noted. The $showads variable can be changed from ‘1’ to whatever post you want it to display after.
    Save the file.
    Here is a simple example. It will show ads after the 5th post of a page.

    <?php $postnum = 1; $showads = 5; ?>
    <?php if ($posts) : foreach ($posts as $post) : start_wp(); ?>
    <?php the_content(); ?>
    <?php if ($postnum == $showads) { ?> <<ADD ADVERTISING HERE>> <?php } $postnum++; ?>
    <?php endforeach; else: ?>
    There are no posts!
    <?php endif; ?>

    and i couldnt find any of those.

    Thread Starter tunedtech

    (@tunedtech)

    and here is the code i have on my index.php right now

    <?php get_header(); ?>

    <div id=”content”>

    <div id=”contentleft”>

    <div class=”postarea”>

    <?php include(TEMPLATEPATH.”/breadcrumb.php”);?>

    <?php $postnum = 1; $showads = 1; ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <h1><?php the_title(); ?></h1>

    <div class=”date”>

    <div class=”dateleft”>
    <p><span class=”time”><?php the_time(‘F j, Y’); ?></span> </p>
    </div>

    <div class=”dateright”>
    <p><span class=”comment”>#respond”>Leave a comment</span></p>
    </div>

    </div>

    <?php the_content(__(‘Read more’));?><div style=”clear:both;”></div>

    <div class=”postmeta”>
    <p><span class=”tags”>Tags: <?php the_tags(”) ?></span></p>
    </div>

    <!–
    <?php trackback_rdf(); ?>
    –>

    <?php endwhile; else: ?>

    <p><?php _e(‘Sorry, no posts matched your criteria.’); ?></p><?php endif; ?>

    </div>

    <div class=”adsense-post”>

    <!–To activate your Google AdSense ad, go to your WP dashboard and go to Presentation -> Revolution Music Options and enter your Google Adsense Code.–>

    <?php $adsense_468 = get_option(‘revmusic_adsense_468’); echo stripslashes($adsense_468); ?>

    </div>

    <div class=”comments”>

    <h4>Comments</h4>
    <?php comments_template(); // Get wp-comments.php template ?>

    </div>

    </div>

    <?php include(TEMPLATEPATH.”/sidebar.php”);?>

    </div>

    <!– The main column ends –>

    <?php get_footer(); ?>

    Thread Starter tunedtech

    (@tunedtech)

    and i did the second link that you gave me and this my code looks like.

    <?php get_header(); ?>

    <div id=”content”>

    <div id=”contentleft”>

    <div class=”postarea”>

    <?php include(TEMPLATEPATH.”/breadcrumb.php”);?>

    <?php $postnum = 1; $showads = 1; ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <h1><?php the_title(); ?></h1>

    <div class=”date”>

    <div class=”dateleft”>
    <p><span class=”time”><?php the_time(‘F j, Y’); ?></span> </p>
    </div>

    <div class=”dateright”>
    <p><span class=”comment”>#respond”>Leave a comment</span></p>
    </div>

    </div>

    <?php the_content(__(‘Read more’));?><div style=”clear:both;”></div>

    <div class=”postmeta”>
    <p><span class=”tags”>Tags: <?php the_tags(”) ?></span></p>
    </div>

    <?php if ($postnum == $showadsense1) {
    echo ‘
    <script type=”text/javascript”><!–
    google_ad_client = “pub-2657159394848468”;
    /* 300×250, created 10/5/08 */
    google_ad_slot = “6559489829”;
    google_ad_width = 300;
    google_ad_height = 250;
    //–>
    </script>
    <script type=”text/javascript”
    src=”https://pagead2.googlesyndication.com/pagead/show_ads.js”&gt;
    </script>
    ‘;
    } ?>

    <?php $postnum++; ?>
    <?php endwhile; else: ?>

    <p><?php _e(‘Sorry, no posts matched your criteria.’); ?></p><?php endif; ?>

    </div>

    <div class=”adsense-post”>

    <!–To activate your Google AdSense ad, go to your WP dashboard and go to Presentation -> Revolution Music Options and enter your Google Adsense Code.–>

    <?php $adsense_468 = get_option(‘revmusic_adsense_468’); echo stripslashes($adsense_468); ?>

    </div>

    <div class=”comments”>

    <h4>Comments</h4>
    <?php comments_template(); // Get wp-comments.php template ?>

    </div>

    </div>

    <?php include(TEMPLATEPATH.”/sidebar.php”);?>

    </div>

    <!– The main column ends –>

    <?php get_footer(); ?>

    but still nothing showing to my page

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘adding adsense each of my latest post’ is closed to new replies.