1

I'm working on a project (AMP website) where I have buttons that should only show up at certain locations and be hidden at other locations. However, I'm struggling to make each of the selected locations have different links. Even GPT-4 couldn't solve this issue for me. Here is the code I'm currently using:

First, here is my CSS and HTML setup:

<center>
<div id="custom-country-button-container-2">
    <a href="https://1" class="bonus-button geo-button">play</a>
</div></center>
<?php if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) : ?>
<style amp-custom>
    .geo-button {
        display: none; 
        margin: 10px 0;
    }
    body.amp-geo-group-KZ .geo-button,
    body.amp-geo-group-AZ .geo-button,
    body.amp-geo-group-RU .geo-button {
        display: block; 
width:100% !important;;
text-align:center !important;;
    }
</style>

<amp-geo layout="nodisplay">
    <script type="application/json">
        {
            "ISOCountryGroups": {
                "KZ": ["KZ"],
                "AZ": ["AZ"],
                "RU": ["RU"],
                "default": ["default"]
            }
        }
    </script>
</amp-geo>
<?php endif; ?>
</div>

I've tried to implement the button functionality with AMP, but I encounter issues where the buttons disappear and don't show correctly. Here's the script and additional AMP configuration I'm using:

The problem is that when the buttons are supposed to show up for different countries, they sometimes don't show up correctly (all of them) or not at all. Can anyone help me figure out what I'm doing wrong? Any recommendations on how to properly show different buttons for different locations with the correct links would be greatly appreciated!

4
  • You are using properties that are not amp-valid which may contribute to the problem. Run it thru the validator; fix the validator issues; then update your post.
    – Jay Gray
    Commented Jun 24 at 18:08
  • I did it :) please help me
    – uuu
    Commented Jun 25 at 14:55
  • That does not look valid to me. For example, I know for sure this is invalid: width:100% !important;. Also why double semi-colons? I am uncertain about the <php>. As I recall there are <php> instances in-the-wild but I don't have any bookmarked so no easy way to see how others run AMP with PHP. Again, the validator will signal if/how to use it.
    – Jay Gray
    Commented Jun 26 at 15:08
  • I don't know, but google says my amp page with this code is valid.
    – uuu
    Commented Jun 27 at 9:32

0

Browse other questions tagged or ask your own question.