• My original theme has functions such as do_shortcode() and get_template_part() hard-coded into the theme files. Looks like these functions are not working when I directly add them inside the AMP template files. I also tried your ‘Custom AMP Theme’ from Github. Still has the same issue. Is there a way to make these WP functions work within the AMP templates?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter wrip

    (@wrip)

    Looks like it’s working. I was trying this inside the wrong template file.

    Plugin Contributor ampforwp

    (@ampforwp)

    Hey @wrip

    Thank you so much for using our plugin.

    Great to hear you have resolved the issue by yourself.

    Let me know if you have any questions regarding AMP, i will be happier to help you.

    Thread Starter wrip

    (@wrip)

    Hi @ampforwp

    Yes I do have another question. The output of get_template_part() function gives me some page/post urls that don’t have ‘/amp’ appended. How do I convert those urls into amp urls?

    Plugin Contributor ampforwp

    (@ampforwp)

    Hey @wrip

    thank you so much for using our plugin.

    get_template_part() will not work as expected sometimes with amp and I suggest you to use the code like this to add more

    
    // Related Posts
    function ampforwp_add_element_related_posts( $meta_parts ) {
      $meta_parts[] = 'ampforwp-related-posts';
      return $meta_parts;
    }
    add_filter( 'amp_post_template_file', 'ampforwp_design_element_related_posts', 10, 3 );
    function ampforwp_design_element_related_posts( $file, $type, $post ) {
      if ( 'ampforwp-related-posts' === $type ) {
        $file = AMPFORWP_PLUGIN_DIR . 'templates/design-manager/design-'. ampforwp_design_selector() .'/elements/related-posts.php';
      }
      return $file;
    }

    also if you can share me that piece of code you are adding and that’s not working as expected. So that i can suggest you something

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Certain WP functions not working’ is closed to new replies.