Support » Plugin: AMP for WP - Accelerated Mobile Pages » Custom Page Templates?

  • Resolved bkmacdaddy

    (@bkmacdaddy)


    I’m using a custom theme with custom page templates that utilize Advanced Custom Fields for most of the content. I’ve purchased the Custom Post Type and ACF extensions and they sort of work (see http://bloomintelligence.com/wi-fi-marketing/?amp) but I’m trying to figure out how to make custom page templates in the ampforwp-custom-theme that will utilize the ACF fields properly and so I can have some control over the AMP pages. Is this possible?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor ampforwp

    (@ampforwp)

    Hey @bkmacdaddy,

    Yes, it is possible.

    Just change the lines here: https://github.com/MohammedKaludi/ampforwp-custom-theme/blob/master/ampforwp-custom-theme.php#L53

    into this:

    if ( is_single() || is_page() ) {
      if('single' === $type && !('product' === $post->post_type )) {
        if ( $post->ID == 'POST ID') {
          $file = AMPFORWP_CUSTOM_THEME . '/template/custom-template.php';
        } else {
          $file = AMPFORWP_CUSTOM_THEME . '/template/single.php';
        } 
       }
    }

    You can use this code for any number of pages/posts you want to create.

    Let me know if that helps you or not.

    Regards
    Marqas

    This is great.
    Can you please add this code example to the Documentation of the Custom Theme?

    Thank you.

    Plugin Contributor ampforwp

    (@ampforwp)

    Hey @ivanpr,

    Sure, we will do that.

    Regards
    Marqas

    Thank you.

    Thanks for the response and code. Unfortunately I’m running into all kinds of problems. The code you provided worked fine for calling the page template, but once I created the page template and tested calling a few of my custom fields the page no longer validated for AMP. Is there a certain way to call ACF fields within your plugin’s page templates so it will validate?

    Also, please see http://bloomintelligence.com/wi-fi-marketing/amp/. This is NOT using a page template but the content – which is all from ACF fields – is being displayed twice, and in 2 different formats. Your ACF extension is the culprit, because when I deactivate the extension only the first run-through of content displays and does not display twice. Unfortunately that first run-through is incomplete.

    I’m tearing my hair out for this client trying to figure this out! I appreciate any help.

    Plugin Author Ahmed Kaludi

    (@ahmedkaludi)

    Hi @bkmacdaddy

    Could you share the code of the ACF fields that you are trying to add? I will help you add it properly to your site.

    Regards,
    Ahmed

    Here is a portion of the code I’ve been trying to use. It is just a simple WYSIWYG field, but I also need the code for repeater fields, images, oembed, and more.

    <div class="amp-wp-content amp-wp-article-header amp-loop-list">
    	<div class="amp-wp-content-loop">
    		<?php
    			$sonecontent = get_field('content_section_one');
    			echo $sonecontent;
    		?>
    	</div>
    </div>

    Thanks for your help!

    bkmacdaddy

    (@bkmacdaddy)

    Ahmed Kaludi,

    Any update on this?

    Thanks,

    Brian

    Plugin Contributor ampforwp

    (@ampforwp)

    Hi @bkmacdaddy,

    I apologize for the delay in response.

    We are currently working on it and it will out very soon then you will be able to add the fields data from the WP dashboard directly to the amp pages.

    Thank you very much for your patience.

    Regards
    Marqas

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Custom Page Templates?’ is closed to new replies.