Wordpress Themes - WP Forum at BFA
Click here to register or to donate.
Auto self-registration is not available here - far too many spammers. This forum has many, many backlinks and because of that there is an intense desire among spammers to drop their links here.

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


  #1  
Old Aug 18, 2012, 02:29 PM
theadventurebite
 
136 posts · May 2010
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 02:07 PM
[SOLVED] Adsense between posts on category pages mkellam Center area post/pages 3 Jun 9, 2011 02:21 PM
Adding Adsense code below Title in Single Posts mkellam Center area post/pages 3 May 9, 2011 05:01 PM
Atahualpa AdSense between posts and a little problem. aan Atahualpa 3 Wordpress theme 2 Apr 30, 2010 07:17 AM
adsense in posts fandango777 Center area post/pages 2 Jan 26, 2010 05:30 AM


All times are GMT -6. The time now is 11:29 AM.


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