Support » Plugin: AMP » Custom fields in AMP

  • Hi team,

    I am using custom fields for building my website. But after installing AMP none of the custom fields are getting visible. Can you help me to fix that issue.

    Thanks and regards,
    Proteammaker

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Support James Osborne

    (@jamesosborne)

    @proteammaker If you want to share your site we can take a look, there could be a number of reasons why they are not displaying. Alternatively if you don’t want to share your site please share how you have implemented your custom fields into your site, or share the markup along with the AMP mode you have active.

    @jamesosborne I have uninstalled the AMP since custom fields wasn’t showing and it will affect my followers. I have uploaded how we are using the custom fields. Please see that and let me know any mistakes have been done.

    https://proteammaker.com/wp-content/uploads/2019/10/Capture-1024×263.jpg

    Plugin Support James Osborne

    (@jamesosborne)

    @proteammaker I don’t see anything wrong with that code on first inspection. Are you custom fields working when added via a shortcode into your theme? We might need to check your site in transitional mode to check.

    @jamesosborne we are unaware of those shortcode testing. Can you guide us how to create a shortcode for custom fields and test in our theme?

    Plugin Support James Osborne

    (@jamesosborne)

    @proteammaker I am unsure if you are using custom fields built into your theme, or Advanced Custom Fields. For Advanced Custom Fields you can see here.

    @jamesosborne we are not using custom fields built in our theme. We are using Advanced Custom Fields plugin for building custom fields.

    Plugin Support James Osborne

    (@jamesosborne)

    @proteammaker If you have text based fields you can apply shortcodes such as the below to check if they work in AMP:
    [acf field="field_name"]

    For non text fields, such as a URL you can try the below:

    <?php 
    $link = get_field('link');
    if( $link ): ?>
        <a class="button" href="<?php echo esc_url( $link ); ?>">Continue Reading</a>
    <?php endif; ?>

    If both the above work on your AMP site check with some of your plugins disabled or review the code you’ve used to apply to your site.

    @jamesosborne when we activate AMP plugin it doesn’t even coming to my php file. So even simple print_r statement is not working. Couldn’t understand where I’m making mistake.

    Plugin Support James Osborne

    (@jamesosborne)

    @proteammaker To test without having to enable AP across your site you can enable the plugin and then opt out of posts by default by adding the following to your themes functions.php file:
    add_filter( 'amp_post_status_default_enabled', '__return_false' );

    You can then enable AMP via the toggle for a single post (there is a toggle in each post to enable AMP). You can then check with an ACF shortcode in that post, a single field shortcode to see whether it displays. If you share the URL we can check also.

    Plugin Support Alain Schlesser

    (@schlessera)

    @proteammaker Which mode of the AMP plugin are you using? If you are using the Reader mode, that would explain why not even print_r statements would work, as the Reader mode completely overrides the theme you are using.

    To actually make use of your theme, you’ll need to be in Standard or Transitional mode instead. Note: Don’t go for Standard mode right away, start with Transitional until you fixed all issues.

Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.