Skip Navigation

[Resolved] AMP – Accelerated Mobile Pages with types

This support ticket is created 7 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 6 replies, has 2 voices.

Last updated by Beda 7 years, 7 months ago.

Assisted by: Beda.

Author
Posts
#426284

Hi i would like to add AMP (Accelerated Mobile Pages) to my site: hidden link

It is a new standard added by google to have faster pages. I technically need to add to all my pages a "/AMP/" suffix like "www.site.com/page/amp/" so i need to create new custom template with this.

It is not very easy to explain:

I should need that when it's added the suffix /amp/ it should show another content template based on the the original custom post type.

I don't know how to do it in types.

Example:

hidden link - It shows the standard template* for events
hidden link - It shows another template* for events

hidden link - It shows the standard template* for places
hidden link - It shows another template for places

I would like to know how to set it in the rewrite rule that when the suffix is like that it shows another template*

*for template i mean a layout

#426399

It's not possible.

A Content Template replaces the_content() or the Function a Theme uses to render the content.

Wether your URL is, does not really matter.
If WordPress is displaying a Post it uses the_content and the loop.
That is where the Plugin hooks in.

Your URL Structure is not really WordPress Compatible, as a Post has a Slug and anythign you append to it will change that Slug.

There is a Plugin that lets you add the Slug, hidden link, as you see it will simply create the AMP versions and it lets you cusomize the Templates with PHP.

#437483

I really need to use toolset and not php to create templates about amp pages... I would try to find a solution.
Would you like to help me ?

#437496

I think a possible workaround could be to show a content template when link has params like "?amp=1" or something like this.

It is not necessary to structure urls like "/amp" way

Is there any way ?

#437902

You may try to use HTML Conditional and the ShortCode wpv-search-term.
https://toolset.com/documentation/views-shortcodes/#wpv-search-term
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

In your HTML condition you coudl evalaute the search term "amp" and compare it against let's say 1, or any other value.

Given the result of this Condition you can then call different Content Templates.

So if you call /?amp= it would show that Content Template and if you do not call it, it woudl show another Content Template.

Keep in mind that you want to accelerate your page and HTML conditionals will (slightly) add a performance delay to your site, specially if you have more conditions in one single place.

#437971

I appreciate this way. But there is a question...

My content template has parent layouts. And i don't want it to be present in the "/?amp=1" version.

Actually for example in restaurants post types it is structured like this:

Main Layout (Header & Footer)
> Restaurants Section Layout
> Single Restaurant Content Template

I would the amp version should just be like:

Single Restaurant Content Template

(Without any parent layout)

#438448

Do you mean that you use layouts, and in there, the Content Template cell?

You can not exclude a Layout with HTML conditional.

This must be done in PHP.

The Layout is called with the method illustrated here:
https://toolset.com/documentation/user-guides/layouts-theme-integration/

But if you use Toolset Starter or above Layout integration, you MUST use Layouts, or you will get a White page with no output.

You always must use a Template, even oin WordPress native installs.

So if you are to call different Templates, this will work, but you need to tell that to the Theme in PHP.

You need to evaluate the $_GET parameter and according the results, use or not use Layouts.
hidden link

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.