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, 1 month 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

    Anita
    Participant
    Post count: 7353

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


    Let me help you customize your theme, responsive header, Buddypress, Agentpress or technical issue!
    Visit me here: Cre8tiveDiva.com | Tweet Me! | Plus Me!
    When asking for help, please provide a link or screen shot showing your problem!

    #50601

    braddalton
    Participant
    Post count: 9194

    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.


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #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.