Archived topic
How can I generate a button in AMP page?
8 replies · Started by uglyc on April 30, 2022
Dear Generatepress Team,
Greetings form UC, and I hope you doing well.
I used to generate button for blog post with a shortcode that I found here https://docs.generatepress.com/article/adding-buttons/, and it worked well. However, when I opened the AMP page (Accelebrated Mobile Pages), the button was gone (actually, it became a text, not a button).
So, my question is : how can keep a button remain the same, even when I switch a post page to the AMP edition?
Of course, just let me know if I haven't made myself very clear. Thanks
All the best,
UC
Hi there,
which plugin are you using for AMP ? As there documentation should include how to add CSS to their amp templates.
Hi David,
Thanks for your advice. Currently I'm using the default plugin for amp. Here is it: https://snipboard.io/uJ05Tx.jpg
However, I don't think there is a document showing me how to add CSS to amp templates.
Could you kindly advise how to achieve that?
Thanks very much. Have a nice day.
UC
It depends on what template mode of that plugin you're using - for example this doc of theres explains adding CSS when in Reader Mode:
https://amp-wp.org/documentation/how-the-plugin-works/amp-and-css/#adding-css-to-your-amp-urls
Thanks David,
Yes, currently I'm using the Reader template mode, and I think that I haven't made any other changes to the plugin defalut setting. Unfortunately, I totally have no idea how to code. Could you advise what code should I add in so as to make sure that the button remains the same in the AMP edition? Much Thanks
All the best,
UC
Hello,
Can anyone offer some help for this issue? Much appreciate that.
You need to add this PHP Snippet to your site:
add_action( 'amp_post_template_css', function() {
?>
/* Put Custom CSS below */
<?php
} );
Where it says: /* Put Custom CSS below */ add a copy of the CSS you added for your buttons.
This doc explains how to add PHP:
Hi David,
Thanks very much, it works now.
However, when I try using the Transient option of the AMP plugin, I found that the button remains the same without needing to add PHP Snippet to my site. So my question is:
Which way is better to my site? Adding PHP Snippet or using the Transient option of the AMP plugin? Actually, I'm not sure about their differences.
Have a nice day,
UC
Unfortunately i don't use AMP so i can't advise on which is better.
You may want to ask the Plugin developer for some input.