Add Adsense in Home only in the first post

Community Forums Forums Design Tips and Tricks Add Adsense in Home only in the first post

This topic is: not resolved

Tagged: ,

This topic contains 3 replies, has 3 voices, and was last updated by  Manuel 1 year, 2 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #50576

    Manuel
    Participant
    Post count: 8

    Hi,

    I tried to add adsense in the home page, but only in the first post, i know is a loop but i need to add a banner only in the first post, not in all the post, this is the code I tried:

    function wpsites_display_adsense_home2() {
    if(is_home()) 
        echo '<center><div class="adsense-home"><script type="text/javascript"><!--
    					google_ad_client = "pub-4646869510923718";
    					/* brujeria blanca 350x250 */
    					google_ad_slot = "1998849211";
    					google_ad_width = 300;
    					google_ad_height = 250;
    				//-->
    				</script>
    				<script type="text/javascript"
    				src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    				</script>
    		<center><strong>Enlace Patrocinado</strong></center></div></center>';
    		
    };
    
    add_action('genesis_before_post_title', 'wpsites_display_adsense_home2', 5 );
    
    

    Thanks in advanced!

    #50584

    AC
    Blocked
    Post count: 7712

    You are using a code from Brad Dalton (WPSites.net). You might want to post your question over to him.

    #50601

    braddalton
    Participant
    Post count: 9944

    I did write about this on my blog as well as answer a question on these forums which provides the solution however i cannot find it.

    Basically it uses a conditional tag for the home page and some other code so it only displays the content on the first post which changes as soon as your publish a new one.


    #50734

    Manuel
    Participant
    Post count: 8

    Do you know where i cant find those variables to create that conditional, I already tried different conditionals, but without success.

    I know I need to insert the adsense code after the id=”content”, or only execute the code in the first post

    Brandon, Can you recommend me a tutorial where i can learn how to use the genesis framework, please!

    Thanks!

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.