Jump to content


Photo
- - - - -

Add Google Adsense To Single Posts


Best Answer batman , 20 December 2012 - 07:21 PM

Hi

You go to

http://www.pagelines...ustomize_Plugin

And the youtube on it, here is to see

 

I give you an other rob´s tutorial (it is a reply at forum)

 

Okay, we'll look at this first piece of code from the tutorial:

 
add_action('brandnav_after_nav', 'brandnav_icons');
function brandnav_icons() { ?>
<ul>
<li><a href="http://www.facebook.com/mysite"; target="blank"><img src="http://www.mysite.com/wp-content/themes/pagelines/sections/branding/facebook.png"></a></li>;
<li><a href="#"><img src="http://www.mysite.com/wp-content/themes/pagelines/sections/branding/twitter.png"></a></li>;
</ul>
<?php }

 

Notice this first part:

add_action('brandnav_after_nav', 'brandnav_icons');

function brandnav_icons() { ?>

 

brandnav_after_nav is the hook. This is what determines where your desired content is placed. It's pretty easy to understand since hooks are named accordingly. In this case, brandnav_after_nav means that the content you place in this hook will be placed after the brand navigation. Does that make sense?

 

brandnav_icons is the name given to the content you want to add. You can name it however you'd like, but it's best to give it a descriptive name so that you know what it's for. This name is supposed to go in two places (as shown in the code above).

 

 

I suppose that you can try something like  

Add the following code to Dashboard > Plugins > Editor in the PageLines Customize plugin, inside the functions.php file:

 

 
 
 
add_action('pagelines_loop_after_post_content', 'google_leaderboard_ad'); 
// function name 
function google_leaderboard_ad(){ ?> <div class="leaderboard"> ADD YOUR Custom Ad Code here </div> <?php } 
// end function

 

Please take care, you read my sign below
;)
 
Go to the full post


  • Please log in to reply
12 replies to this topic

#1 christianmolk

christianmolk

    Newbie

  • Members
  • 7 posts
  • Country: Country Flag

Posted 20 December 2012 - 10:55 AM

I would like to add Google AdSense to all my Single posts between the text and the comments, but I do not know where to put the code? And how do I avoid this code to be overwritten every time Pagelines is updated?

 

My website is www.christianmolk.se and I do not use any Child theme, just the standard Pagelines Framework. 



#2 batman

batman

    Bat Learning

  • Members

  • 2004 posts
  • LocationBuenos Aires, Argentina
  • Framework Version:DMS
  • Country: Country Flag

Posted 20 December 2012 - 11:43 AM

Hi

 

You can add an action for add Google AdSense to all Post.

You can find at

Please Login or Register to see this Hidden Content

or use the Action Map Plugin

Please Login or Register to see this Hidden Content

You can see this links to begin:

Please Login or Register to see this Hidden Content

Please Login or Register to see this Hidden Content

Please Login or Register to see this Hidden Content



#3 christianmolk

christianmolk

    Newbie

  • Members
  • 7 posts
  • Country: Country Flag

Posted 20 December 2012 - 12:10 PM

Thank you for the quick reply batman!

 

I have installed and activated the Action Map plugin but I do not see the button on the left hand side of my WordPress admin bar. 



#4 batman

batman

    Bat Learning

  • Members

  • 2004 posts
  • LocationBuenos Aires, Argentina
  • Framework Version:DMS
  • Country: Country Flag

Posted 20 December 2012 - 12:16 PM

Hi again

Go to a Page or post

Captura%2520de%2520pantalla%25202012-12-



#5 christianmolk

christianmolk

    Newbie

  • Members
  • 7 posts
  • Country: Country Flag

Posted 20 December 2012 - 12:18 PM

Yes, I see the Action Map button on your picture but it is simply not there on my Wordpress admin bar. This is very strange since I have both installed and activated the plugin. 



#6 batman

batman

    Bat Learning

  • Members

  • 2004 posts
  • LocationBuenos Aires, Argentina
  • Framework Version:DMS
  • Country: Country Flag

Posted 20 December 2012 - 12:36 PM

Hi 

I don´t know what happened, please clean your cache....

 

but you can use this hook (it´s only and example)

 

pagelines_loop_after_post_content

 

You can see this Danny´s reply for more information (the second reply)

 

Please Login or Register to see this Hidden Content

 

Perhaps you need  wait a professional answer for "The Moderating Team".

 

;)



#7 christianmolk

christianmolk

    Newbie

  • Members
  • 7 posts
  • Country: Country Flag

Posted 20 December 2012 - 05:00 PM

Thanks for your answers batman. If I am to use these "hooks", how do I locate them and where do I put the Google AdSense code?



#8 batman

batman

    Bat Learning

  • Members

  • 2004 posts
  • LocationBuenos Aires, Argentina
  • Framework Version:DMS
  • Country: Country Flag

Posted 20 December 2012 - 07:21 PM   Best Answer

Hi

You go to

Please Login or Register to see this Hidden Content

And the youtube on it, here is to see

 

I give you an other rob´s tutorial (it is a reply at forum)

 

Okay, we'll look at this first piece of code from the tutorial:

Please Login or Register to see this Hidden Content

 

Notice this first part:

add_action('brandnav_after_nav', 'brandnav_icons');

function brandnav_icons() { ?>

 

brandnav_after_nav is the hook. This is what determines where your desired content is placed. It's pretty easy to understand since hooks are named accordingly. In this case, brandnav_after_nav means that the content you place in this hook will be placed after the brand navigation. Does that make sense?

 

brandnav_icons is the name given to the content you want to add. You can name it however you'd like, but it's best to give it a descriptive name so that you know what it's for. This name is supposed to go in two places (as shown in the code above).

 

 

I suppose that you can try something like  

Add the following code to Dashboard > Plugins > Editor in the PageLines Customize plugin, inside the functions.php file:

 

Please Login or Register to see this Hidden Content

Please Login or Register to see this Hidden Content

Please Login or Register to see this Hidden Content

 

Please take care, you read my sign below
;)
 


#9 christianmolk

christianmolk

    Newbie

  • Members
  • 7 posts
  • Country: Country Flag

Posted 03 January 2013 - 06:14 PM

I used the code you wrote and it worked almost perfectly! The only issue I have now is how to not show my Google Ads on the front page. Is there any more code to ad to make this happen?



#10 catrina

catrina

    Advocate

  • Members
  • 12345 posts
  • LocationCalifornia
  • Country: Country Flag

Posted 03 January 2013 - 06:17 PM

As a workaround for hiding the ad banner on your front page, you can try hiding them with custom CSS:

 

Please Login or Register to see this Hidden Content

Please Login or Register to see this Hidden Content

(use display: none)



#11 christianmolk

christianmolk

    Newbie

  • Members
  • 7 posts
  • Country: Country Flag

Posted 03 January 2013 - 06:53 PM

I tried using the code ".home #ads {display:none;}" but it did not do anything. Any ideas?



#12 batman

batman

    Bat Learning

  • Members

  • 2004 posts
  • LocationBuenos Aires, Argentina
  • Framework Version:DMS
  • Country: Country Flag

Posted 03 January 2013 - 07:28 PM

Hi again

You can try with

.home .leaderboard { display:none; }



#13 christianmolk

christianmolk

    Newbie

  • Members
  • 7 posts
  • Country: Country Flag

Posted 03 January 2013 - 07:54 PM

Thank you batman! That actually worked just as I wanted it to!  :thumbsu: