Add Adsense Code On Homepage After Two Post Counts
Best Answer Simon_P , 15 December 2012 - 04:40 PM
Your code will not work as it is copy and pasted from thesis hook.
add_action('pagelines_loop_after_excerpt', 'after_first_post_ad');
function after_first_post_ad($post_count) {
if (is_home()) {
global $post_ad_count;
if ($post_ad_count == 2) { ?>
<!-- GOOGLE AD CODE START HERE -->
<script type="text/javascript"><!--
google_ad_client = "ca-pub-34XXXXXXXXXXXXXXX";
/* Top-Sidebar-300x250*/
google_ad_slot = "4089184913";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googl...ead/show_ads.js">
</script>
<!-- GOOGLE AD CODE ENDS HERE -->
<?php
}
$post_ad_count++;
}
}
Go to the full post
#1
Posted 15 December 2012 - 07:19 AM
#2
Posted 15 December 2012 - 11:45 AM
Manoj,
In cases such as this, I'm afraid such a customization takes the help of a Pro because trying to break into the loop can cause harm to your site. So, I'd refer you to
On the flip side of that, What I have done in past is to use and the . This would allow you to emulate the loop using customized shortcode you create yourself and some easy CSS. Both plugins are free, but have premium versions at CodeCanyon.net.
Place Special Recent Posts shortcode on a static homepage for the 1st two posts. You may have to use CSS to resize the thumbnail, but it's very easy to do.
Below it, using the Boxer plugin, which creates content blocks, insert the shortcode for a block-set. The block set has one box, and it contains the AdSense code.
Following this, more shortcode for Special Recent Posts, this one offsetting the post list by 2, and displaying 8 or whatever number you'd like.
So, the page would have
- 2 posts
- ad
- 8 posts
That seemed to be the layout you were seeking.
Note: If you were going to style the ads, such as centering, you can still do so with the content block. Simply wrap the code in a unique class and use CSS to align the ad as desired. You may also be able to achieve this with the settings of Boxer plugin.
#3
Posted 15 December 2012 - 04:06 PM
I don't want to use plugins. Thanks for not providing straight solution.
#4
Posted 15 December 2012 - 04:40 PM Best Answer
Your code will not work as it is copy and pasted from thesis hook.
#5
Posted 15 December 2012 - 05:54 PM
Since you refuse my recommended solution and are using the wrong code to begin with, perhaps you'll now hire a Pro, as suggested. We cannot customize your site for you via the forum. Customizations are done by professional web designers on our team.
I tried offering you a viable option, which you rejected. I'm sorry my solution was unsatisfactory and wish you only the best luck with your project.
#6
Posted 31 December 2012 - 02:49 PM
Thanks for being "Harsh"
Also tagged with one or more of these keywords: pagelines
PageLines Framework →
Customizations →
I only want quickslider on one blog postStarted by c_p_p , 13 May 2013 |
|
|
||
PageLines Blocking Cron Job?Started by go9media , 25 Apr 2013 |
|
|
||
PageLines Framework →
Technical Support →
Missing Footer?Started by bluefantail , 23 Apr 2013 |
|
|
||
Remove Feature Link When No Link SpecifiedStarted by justinn , 22 Apr 2013 |
|
|
||
Remove shadow under Feature,Started by stefanoferruggiara , 06 Apr 2013 |
|
|











