Support » Plugin: AMP » Google Ads Don't Show Up On AMP Pages

Viewing 15 replies - 1 through 15 (of 29 total)
  • AMP = No ads

    Imagine to be like… reader mode in safari, where things are dropped and removed for the sake of speed

    Google ads are now supported for AMP:

    Google Announces New Advertising Support For AMP Pages

    So how do we implement them?

    I am not a developer, so don’t beat me if this is stupid. I solved the problem in this way:
    1. Locate this line in your template.php file:
    <?php echo $amp_post->get_content(); ?>
    This is the code to produce the content, as I assume…

    2. Add the following code directly above this line to get an adsense ad directly above the content:

    <div class="ad-container">
    <amp-ad width="auto" height="250"
            type="adsense"
            data-ad-client="ca-pub-xxxxxxxxxxxxxxx"
            data-ad-slot="xxxxxxxxxxxxxx">
        </amp-ad>
      </div>

    Replace the xxxxxxxxxx with your own ID’s. You will find them if you create a new ad in adsense.

    You could add the same code below the content generation line and you can change width and height according to your needs.

    Here is an example: http://amazingtemples.com/location/america/mexico/yucatan-getting-around/amp/

    Would be interested to hear the opinion of developers about this solution…

    Hey Crischo,

    No ads are showing up on the link you have.

    I think with this plugin, you’ll still need to tinker a lot with style on your website template to make it look closer to your original too.

    Thankfully, our developer said they’ve added enough in this plugin to make it easy to do that so logo can be included again plus other things so it doesn’t look so stark but still fits the AMP requirements.

    Plugin Author Mohammad Jangda

    (@batmoo)

    We’ll have an update pushed out soon that adds lots of customization options, which will allow inserting ads and changing the look and feel of the template. I’ll reply here once the update is live.

    Thanks Mohammad, I’m waiting for the ads integration. OK for the speed but we have also to work with that pages.

    This project seems very promising, the very Google invited me to test this wonder, thought WordPress was already in the group involved is why I love this platform.

    It is still very simple this version of the plugin:

    http://www.teciber.com/test/amp

    I hope that the future version updates change this situation.

    Any Update on latest build which supports ads?

    @ehliyetco – How did you get that working?

    I’m using the latest version of that plugin, and I have my <amp-ad> tag in the HTML which shows up in the regular view, but not in the /amp version.

    Does the <amp-ad> tag need to be inserted a special way, maybe using a WP filter or something?

    @arsenalist i use code inserter (Seo Ultimate). Before Item Content and After Item Content

    Here is my actual version. Works well on two different websites. I used a code snippet from the readme file of the AMP GitHub Archive (thx. Mohammad Jangda!)

    I adjusted it and wrote it to the functions.php of my child theme.
    Not sure if this is perfect code, but it works for me.

    add_action( 'amp_post_template_footer', 'xyz_amp_add_advertisement' );
    function xyz_amp_add_advertisement( $amp_template ) {
        $post_id = $amp_template->get( 'post_id' );
        ?>
        <?php
    { //Advertisement
    printf(' <div class="amp-wp-content"><amp-ad width=auto height=200
        type="adsense"
        data-ad-client="ca-pub-XXXXXXXXXXXXXXX"
        data-ad-slot="XXXXXXXXXXXXXXXXX">
    </amp-ad></div>');
    }
    ?>
        <?php
    }

    >>> Here is an example link – The advertisement shows up in the Footer

    Thanks everyone. Yes, I got it working. Basically, you can’t just put the ad code in your template file. It has to be inserted via a filter or an action.

    So, for me, it was using the the_content filter.

    Thank you.

    Hi Mohammad,
    any update on this yet? Looking forward to the official Ads support. I add my ads dynamically within certain paragraphs of my content so adding the ads on footer will not help me. Right now when I see the scource code it shows me like <ins class="adsbygoogle center top-ad" data-ad-client="ca-pub-12345" data-ad-slot="12345"></ins> but no ads shows up in the middle.

    Please push an update to fix this.

    +1 for this fix….

    I use code inserter and still no ads… so i disable the amp for the moment.

Viewing 15 replies - 1 through 15 (of 29 total)
  • The topic ‘Google Ads Don't Show Up On AMP Pages’ is closed to new replies.