Wordpress Themes - WP Forum at BFA
There will be no more development for Atahualpa (or any other theme), and no support. Also no new registrations. I turned off the donation system. I may turn the forum to read only if it gets abused for spam. Unfortunately I have no time for the forum or the themes. Thanks a lot to the people who helped in all these years, especially Larry and of course: Paul. Take care and stay healthy -- Flynn, Atahualpa developer, Sep 2021

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » Center area post/pages »

How To Add Adsense between Posts without a widget


 
Prev Previous Post   Next Post Next
  #1  
Old Aug 18, 2012, 01:29 PM
theadventurebite
 
136 posts · May 2010
How To Add Adsense between Posts without a widget

Hey all,

Thought I would take a second to share how I figured out how to add Adsense between posts 1 and 2 without a widget. Juggledad's great tutorial here on how to do it with a widget was the basis of this, but I decided I didn't like the look of the widget area between the posts.

I am using an older version so I actually had to take 3.7.7's index.php and copy the top part in its entirety to get this to work right.

Here is the full code:
Code:
<?php 
list($bfa_ata, $cols, $left_col, $left_col2, $right_col, $right_col2, $bfa_ata['h_blogtitle'], $bfa_ata['h_posttitle']) = bfa_get_options();
get_header(); 
extract($bfa_ata); 
global $bfa_ata_postcount;
?>

<?php /* If there are any posts: */
if (have_posts()) : $bfa_ata_postcount = 0; /* Postcount needed for option "XX first posts full posts, rest excerpts" */ ?>

	<?php // Deactivated since 3.6.5
	# include 'bfa://content_above_loop'; 
	// Uses the following static code instead: ?>
	<?php bfa_next_previous_page_links('Top'); // For MULTI post pages if activated at ATO -> Next/Previous Navigation:  ?>

	<?php while (have_posts()) : the_post(); $bfa_ata_postcount++; ?>

<?php $show_widget_after_post = 1;
if ($bfa_ata_postcount == ($show_widget_after_post + 1)) { echo '<div align="center" style="padding-bottom:8px; padding-top:3px; ">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-4976060676917875";
/* Square Between Posts */
google_ad_slot = "2257642737";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>';} ?>
If you are already on the current version you don't have to copy all of that just place this:

Code:
<?php $show_widget_after_post = 1;
if ($bfa_ata_postcount == ($show_widget_after_post + 1)) { echo '<div align="center" style="padding-bottom:8px; padding-top:3px; ">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-4976060676917875";
/* Square Between Posts */
google_ad_slot = "2257642737";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>';} ?>
below this
Code:
<?php while (have_posts()) : the_post(); $bfa_ata_postcount++; ?>
You can adjust the padding and DIV elements around the ad, and of course replace my ad script with yours.

Hope that helps someone!

Dani
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adsense Ads On Posts ONLY carbyville Center area post/pages 1 Nov 1, 2011 01:07 PM
[SOLVED] Adsense between posts on category pages mkellam Center area post/pages 3 Jun 9, 2011 01:21 PM
Adding Adsense code below Title in Single Posts mkellam Center area post/pages 3 May 9, 2011 04:01 PM
Atahualpa AdSense between posts and a little problem. aan Atahualpa 3 Wordpress theme 2 Apr 30, 2010 06:17 AM
adsense in posts fandango777 Center area post/pages 2 Jan 26, 2010 04:30 AM


All times are GMT -6. The time now is 11:45 PM.


Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.