Tagged: ,

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

    Hello friends:
    Google Adsense automatic ads are automatically displayed in the best place on the page. Now, I have inserted the adsense code in the Header of the plugin “Header and Footer Scripts” and works fine but the problem is that I get ads on all pages, while I want them to go out alone in the posts. So I think I have to manually place the code in the header, but I do not know where and how.

    Finally my question is: Where can I place the Adsense code so that the ads only appear in the posts and in no other pages included the home page?

    I’ll appreciate any help for your side.
    Best Regards,
    Jose Ramon

    • This topic was modified 6 years, 8 months ago by Jose Ramon.
    #945072

    Hey José Ramón,
    This is the first time I’ve heard of Google Adsense automatic ads, but I believe that within your Adsense control panel you should be able to exclude pages of your site, I recommend looking for the correct way there.
    But another method would be to use a conditionally function in WordPress to only post the header code on posts. First remove your Adsense header code, then add it to this function in your functions.php
    *Hopefully you are using a child theme because when editing functions.php you should use the child theme, so your changes will not be lost with future theme updates Read about it & Get it here

    // adsense code only on single posts
    function add_custom_adsense(){
    	if ( is_single() ) {
    ?>
    <script>
    //ADD YOUR ADSENSE CODE HERE
    </script>
    <?php
    }
    }
    add_action('wp_head', 'add_custom_adsense');

    Best regards,
    Mike

    #945083

    Hi Mike:
    Works fine with your code!
    Thank you so much.

    Best Regards,
    José Ramón

    P.D. Yes, I’m using Enfold child theme

    #945091

    Hi,
    Glad we were able to help, we will close this now. Thank you for using Enfold.

    For your information, you can take a look at Enfold documentation here
    and the video tutorials here
    And if there are features that you wish Enfold had, you can request them and vote the requested ones here
    For any other questions or issues, feel free to start new threads under Enfold sub forum and we will gladly try to help you :)

    Best regards,
    Mike

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘New Automatic Google Adsense Ads; want ads only in the post and no in pages.’ is closed to new replies.