Question

Posted · Report post

My website is www.theflightattendantlife.com

What [b]I want to do is place Google Adsense Leaderboard Ads in certain places on the different pages.[/b]

[i]The Front Page: [/i]

I want an ad below the features section

For the following pages:

[i]About, Where I've Been, Upcoming Adventures, Inflight Dietitian, Flight Fashion[/i]

I want an ad placed right below the header.

[b]My question is, should I use the callout section, masthead, features...??? to place the code. Just want to know the best way to do this.[/b]

Thanks

Share this post


Link to post
Share on other sites

10 answers to this question

  • 0

Posted · Report post

All hooks, are added to your child themes functions.php file.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Hi,

To position this correctly, you would probably be best using a hook. First thing you should do is go to the PageLines store and install the free plugin called Action Map. Once installed, go to your homepage, refresh your site and in the top left hand side of your Wordpress admin bar, a new link should be visible called Action Map. Clicking this link, will load all the hook locations on your site, this will assist in locating the correct position for you to add your Google Leader-board.

Below is just an example of a hook and will not actually work, you will need to amend the code.

[CODE]
add_action('pagelines_inside_top_branding', 'google_lb_ad');

// function name
function google_lb_ad(){ ?>

Add Google Ad Code Here

}
[/CODE]


You may need to use CSS to style and position the ad correctly.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Hey Danny,

 

I have used the recommended PHP function that you provided in Comment #2 and that works great for a standard desktop browser.  My problem now is when a mobile browser is used, such as that on an iPhone, the adsense ad is not resized.  My assumption would be that I would also need to have a mobile version of the advertisement, but I am not sure how to appropriately switch between the two dependent on the user-agent.

 

 

Any help would be appreciated!

 

- DIY Property Manager

 

http://diypropertymanagement.com

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Hi there, I'd say check back with google to see if the add has a set width/height in pixels or if there's a code for a responsive version. Usually responsive sizes are done in percentages not set figures such as 300px etc.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Google does not provide a responsive advertisement, everything must be taken care of through JS and CSS apparently.  Here is something that I found during a search...

 

 

 

<script type="text/javascript">
    google_ad_client = "ca-publisher-id";
    if (window.innerWidth >= 800) {
        google_ad_slot = "ad-unit-1";
        google_ad_width = 728;
        google_ad_height = 60;
    } else if (window.innerWidth < 400) {
        google_ad_slot = "ad-unit-2";
        google_ad_width = 300;
        google_ad_height = 250;
    } else {
        google_ad_slot = "ad-unit-3";
        google_ad_width = 468;
        google_ad_height = 60;
    }
</script>
<script type="text/javascript" 
 src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Your ad (as with all non-mobile Google Adsense) is designed for a static sized view.  You'll note their code includes 728 and 90, which are pixel sizes.  Those ads will likely not resize in Mobile View.

 

Go to Dashboard > PageLines > Site Options > Website Setup and check the box to Disable Mobile View.  Your site will still be fully responsive, yet it will look exactly as it does in a non-mobile computer.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Hello. Where do I actually add the code for the hook? In my case, I want to place a google ad in pagelines_before_postloop, and want to add code like this to loop_start (or something like this. It's what I used in the previous version of the site with a completely different theme):

 

<?php while ( have_posts() ) : the_post() ?>
<?php $loopcounter++; if (($loopcounter == 1) || ($loopcounter == 2)) { # 2 ads per page 
?>
<div class="adsense" style="text-align:center;">
What's That Bug? does not endorse extermination<br />
<script type="text/javascript"><!--
google_ad_client = "pub-0148903435359348";
/* 300x250, created 9/14/08 */
google_ad_slot = "6218044538";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Thanks again! I didn't do a child theme yet - I added a line at the end of functions.php that calls child_functions.php. That way when I upgrade I just have to remember to add that line back in, but my changes won't get stepped on. I'll tackle child themes at some other point, but this buys me time while I get the site looking closer to the way I want.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Hi there Danny...

 

My website is still based on framework. I am in the process of building a new site in DMS.

 

While that is happening, I have signed up with Google Adsense to display ads on the Pagelines site. Adsense has amended their code to adjust the size of ads in a way that is responsive to differing devices. However, my ads do not adjust.

 

I have removed the ads until I can fix my issue.

 

Info on Adsense indicates that this problem exists and suggests reasons why it might be - https://support.google.com/adsense/answer/3213689

 

I had placed my ad code on my front page via custom code in the Asynchronous Analytics section.

 

I placed a second ad in the side bar via a text widget. All worked fine, except that the size of the ads would not adjust for size on different devices.

 

Would you have some pointers as to what I do about this in Pagelines Framework (and DMS for that matter)?

 

With thanks...

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

webmaster021801 - What you're using isn't PageLines code, if this isn't working, you will need to provide a link to the site in question, so we can see the issue.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now