=== AMP WP - Google AMP For WordPress ===
Contributors: mohsinrafique, pixelative
Donate link: https://wise.com/pay/me/mohsinr301
Tags: AMP, accelerated mobile pages, Google AMP, mobile, page speed
Requires at least: 5.0
Tested up to: 6.9.4
Requires PHP: 7.4
Stable tag: 1.7.8
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
The most complete free AMP plugin for WordPress. Supercharge mobile performance with Google Accelerated Mobile Pages, no coding required.
== Description ==
**AMP WP** is the most feature-rich, developer-friendly, and beginner-ready Google AMP plugin available for WordPress, completely free.
Originally built by **[Pixelative](https://pixelative.co)**, a professional web development agency, AMP WP is now independently developed and maintained by **[Mohsin Rafique](https://mohsinrafique.com)**, the lead engineer behind the plugin since its inception. AMP WP has helped thousands of website owners dramatically improve mobile page speed, search rankings, and user experience.
[Online Demo](https://pixelspress.com/amp) | [CF7 Premium Extension](https://1c8979da.sibforms.com/serve/MUIFAPfaW_zG5aVJNBG78I1qIu30utV8kT5_ERiosqVMstRk9Nj1o6RVbEbyaJkvyZ9TQ3b79YDkpPjsyd99NmbxAlNtZQrx9TkcFAF3V6DvgcoiCcnaZkgvPxl_OpctNUzI-G7xDKxwMq2d2Cm2RteW4LoOxEi-XMmdvhfCiMDxfBsOx18Pd9U1xsTcOqIdyT9WccheL83rrsCeeQ==) | [Support](mailto:mohsin.rafique@gmail.com)
---
### Why AMP WP?
Google's Accelerated Mobile Pages (AMP) technology delivers pages up to **5x faster** on mobile devices. Faster pages mean lower bounce rates, higher engagement, and better rankings in Google Search. AMP WP makes enabling AMP on your WordPress site effortless, from a single settings panel with no theme modifications needed.
---
### Free Features
**Performance & Compatibility**
* Full Google AMP specification compliance (100% valid AMP output)
* PHP 8.x compatible (tested through PHP 8.4)
* Compatible with all major caching plugins (WP Rocket, SG Optimizer, W3 Total Cache, and more)
* Compatible with Jetpack
* Compatible with Yoast SEO (100%)
* Compatible with "Automattic AMP" plugin
* Gutenberg block editor support
* RTL language support (100%)
* GDPR compliant
**Content & Embeds**
* Automatic AMP conversion for Posts, Pages, and Custom Post Types
* Embed Images, Videos, Audios, and iFrames: YouTube, Vimeo, Twitter, Facebook, SoundCloud, Instagram (Posts, Reels & TV)
* Lightbox for Images
* Slider Support
* Internal AMP Linking
* Native AMP Search
**Design & Customization**
* Two listing layouts: Classic View and List View
* Customizable color scheme
* Custom CSS options
* Sticky Header
* AMP WordPress Navigation Menu
* Custom AMP Front Page
* Social Icons
**Control**
* Show/Hide AMP for individual Posts, Pages, and Custom Post Types
* Show/Hide AMP for Taxonomies (Categories, Tags, Custom)
* Show/Hide AMP mobile redirections
* Show/Hide AMP on Search pages
* Show/Hide Date, Author, and Thumbnail across Archive, Single Post, Related Posts, and Slider
* Show/Hide Tags on Single Post pages
* Enable/Disable Structured Data (JSON-LD Schema)
**Engagement & Analytics**
* Related Posts (with thumbnail, date, and author controls)
* Recent Comments
* Notice Bar
* Sidebar
* Social Sharing Buttons
* OneSignal Push Notifications integration
* Third-party analytics support: Google Analytics, Facebook Pixel, Segment, Quantcast, Alexa Metrics, Chartbeat, comScore, Yandex Metrica, AFS Analytics, Adobe Analytics
**Ads**
* Google AdSense Auto Ads for AMP support
**Multilingual**
* Translation Panel included
* Contact us at `mohsin.rafique@gmail.com` to contribute translations
---
### Maintained by Mohsin Rafique
AMP WP was originally created by **[Pixelative](https://pixelative.co)**, a full-service digital agency specializing in high-performance WordPress solutions, and remains under Pixelative's ownership. The plugin is currently developed, updated, and supported independently by **Mohsin Rafique**, a seasoned WordPress engineer with deep expertise in AMP specification compliance, PHP performance, and modern web standards.
For support, custom AMP theme development, or white-label licensing, contact **Mohsin Rafique** at [mohsinrafique.com](https://mohsinrafique.com) or [mohsin.rafique@gmail.com](mailto:mohsin.rafique@gmail.com).
---
= Credits =
* [WordPress Plugin Boilerplate Generator](https://wppb.me/) by Tom McFarlin, License: GPLv2
* [normalize.css](http://necolas.github.io/normalize.css/), License: MIT
* [Karla](https://fonts.google.com/specimen/Karla) by Jonathan Pinhorn, License: SIL OFL
* [Noto Sans](https://fonts.google.com/specimen/Noto+Sans) by Google, License: SIL OFL
* [Overpass Mono](https://fonts.google.com/specimen/Overpass+Mono) by Delve Withrington, License: SIL OFL
* [Font Awesome Free 6.7.2](https://fontawesome.com/license) by Fonticons, Inc., Font: SIL OFL 1.1 / Code: MIT
== Installation ==
=== Minimum Requirements ===
* WordPress 5.0 or higher
* PHP 7.4 or higher
* MySQL 8.0+ or MariaDB 10.5+
**Tip:** Install [Regenerate Thumbnails](https://wordpress.org/plugins/regenerate-thumbnails/) and regenerate your thumbnails after activation to ensure the post listing layout renders correctly.
=== Automatic Installation (Recommended) ===
1. Log in to your WordPress admin panel.
2. Navigate to **Plugins -> Add New**.
3. Search for **AMP WP**.
4. Click **Install Now**, then **Activate**.
5. Go to **AMP WP -> Customize AMP** to configure your settings.
=== Manual Installation ===
1. Download the plugin ZIP from the WordPress plugin repository.
2. Extract the ZIP and upload the `amp-wp` folder to `/wp-content/plugins/` via FTP or your hosting file manager.
3. Activate the plugin from **Plugins** in your WordPress admin panel.
4. Navigate to **AMP WP -> Customize AMP** to begin setup.
== Frequently Asked Questions ==
= What is the URL structure for AMP pages? =
AMP WP supports two URL formats:
1. **Prefix format:** `https://yoursite.com/amp/page-name`
2. **Suffix format:** `https://yoursite.com/page-name/amp`
You can choose your preferred format from **AMP WP -> Settings -> General**.
= How do I add analytics tracking? =
Go to **AMP WP -> Settings -> Analytics** in your WordPress admin dashboard. AMP WP supports Google Analytics, Facebook Pixel, Segment, Quantcast, Alexa Metrics, Chartbeat, comScore, Yandex Metrica, AFS Analytics, and Adobe Analytics.
= The post listing layout looks broken: how do I fix it? =
This is usually caused by inconsistent thumbnail sizes. Install and run [Regenerate Thumbnails](https://wordpress.org/plugins/regenerate-thumbnails/) to normalize all image sizes.
= Does AMP WP support Instagram Reels and TV posts? =
Yes. Since version 1.6.0, AMP WP supports Instagram `/p/`, `/reel/`, and `/tv/` post types natively via `amp-instagram`.
= What prebuilt listing layouts are available? =
Two layouts are included: **Classic View** and **List View**. Switch between them from **AMP WP -> Options Panel**.
= How do I inject custom HTML (e.g., ad codes, analytics snippets)? =
Go to **Dashboard -> AMP WP -> Customize AMP**. You can inject valid AMP snippets:
* Between `
` tags
* Right after the `` opening tag
* Right before the `` closing tag
Only valid, AMP-compatible code will function on AMP pages.
= How do I enable AdSense Auto Ads for AMP? =
**Recommended path (AMP WP 1.7.7 and later):**
1. Open **Dashboard -> AMP WP -> Settings -> General**.
2. Scroll to the **Google Auto Ads** section.
3. Tick the **Enable Google Auto Ads** checkbox and click **Save Changes**.
When the toggle is on, AMP WP automatically takes care of both halves that AdSense Auto Ads needs on every AMP page:
* The `amp-auto-ads` runtime loader (``) is injected inside `` via the canonical AMP component pipeline.
* The matching `` element is emitted right after `` so the AMP validator sees the extension as "used" and AdSense can place anchor, vignette, and in-page ads.
**Where does the publisher ID come from?**
* **With Google Site Kit installed and AdSense connected:** the publisher ID is read automatically from Site Kit's stored AdSense module setting (no extra typing needed).
* **Without Site Kit:** supply your `ca-pub-...` value via the `amp_wp_adsense_publisher_id` filter. Drop this into your theme's `functions.php` or a small mu-plugin:
`add_filter( 'amp_wp_adsense_publisher_id', function() { return 'ca-pub-XXXXXXXXXXXXXXXX'; } );`
The filter accepts any of the three plausible input shapes - `ca-pub-XXXX`, `pub-XXXX`, or the bare numeric ID - and AMP WP normalises the value before output. If no publisher ID is resolvable, AMP WP silently skips the body-side element so the page stays validator-clean.
**Manual fallback (non-AdSense ad networks, custom snippets):**
Navigate to **Dashboard -> AMP WP -> Customize AMP**. Paste the runtime loader script in the *"Codes between `` and `` tags"* field, and your `` (or other AMP-valid ad markup) in the *"Codes right after `` tag"* field. When you later enable the native **Google Auto Ads** toggle, AMP WP auto-cleans any manually-pasted `amp-auto-ads` loader from the head-code field and surfaces a one-shot admin notice confirming the cleanup, so the native injection path remains the single source of truth.
[AdSense Auto Ads for AMP - Google Help](https://support.google.com/adsense/answer/9011465)
= How do I enable or disable AMP for a specific post? =
Edit the post in WordPress, scroll to the **AMP WP** meta box in the sidebar, and toggle the AMP option on or off for that individual post.
= How do I report a bug or request a feature? =
Please email `mohsin.rafique@gmail.com` or open a thread on the [WordPress support forum](https://wordpress.org/support/plugin/amp-wp/).
== Developer Hooks ==
AMP WP exposes WordPress-standard actions and filters throughout its template system, URL generator, structured data engine, and admin panel. All hooks listed here are safe to use in a child theme's `functions.php` or in a standalone plugin. No plugin file edits are needed.
= Template Actions =
These actions fire inside AMP WP's own template system. They do not use `wp_head` or `wp_footer`. Output must be valid AMP markup.
**`amp_wp_template_head`**
Fires inside the AMP `` element. Use for custom meta tags or other head markup. AMP WP reserves priority 0 for component scripts.
**`amp_wp_template_head_deferred`**
Fires in `` after the AMP boilerplate styles have been written. Required injection point for `` and any snippet that must follow the boilerplate. AMP WP's own styles and scripts output here.
**`amp_wp_template_body_start`**
Fires immediately after the opening `` tag.
**`amp_wp_body_beginning`**
Fires at the start of visible body content, before the site header renders.
**`amp_wp_post_content_below`**
Fires directly below the post content on single post pages.
**`amp_wp_template_footer`**
Fires before the closing `` tag. Priority 999 is reserved for AMP WP's output sanitizer.
**`amp_wp_template_enqueue_scripts`**
Use to register additional AMP component scripts. Call `amp_wp_enqueue_script( $handle, $src )` inside your callback.
**`amp_wp_after_comment_list`**
Fires after the comment list on single post pages.
**`amp_wp_notifications_bar`**
Fires inside the notification/notice bar template slot.
**`amp_wp_gdpr_compliance`**
Fires inside the GDPR banner template slot.
= Analytics Actions =
These actions fire in the AMP page footer. Each corresponds to one analytics provider already supported by AMP WP. Hook into any of them to append a custom `` block for a provider not yet built in, or to modify the existing output before it renders.
* `amp_wp_analytics_ga` (Google Analytics)
* `amp_wp_analytics_fbp` (Facebook Pixel)
* `amp_wp_analytics_sa` (Simple Analytics)
* `amp_wp_analytics_qc` (Quantcast)
* `amp_wp_analytics_acm` (Adobe Campaign Manager)
* `amp_wp_analytics_cb` (Chartbeat)
* `amp_wp_analytics_comscore` (comScore)
* `amp_wp_analytics_yandex_metrica` (Yandex Metrica)
* `amp_wp_analytics_afs` (AFS Analytics)
* `amp_wp_analytics_adobe` (Adobe Analytics)
= AMP Version Control Filters =
**`amp_wp_amp_version_exists`**
Control whether an AMP version is served for the current request. Return `false` to disable AMP for that page.
Parameter: `(bool) $exists`
`add_filter( 'amp_wp_amp_version_exists', '__return_false' );`
**`amp_wp_template_auto_redirect`**
Enable automatic redirection of all visitors from the non-AMP URL to the AMP URL. Default `false`.
Parameter: `(bool) $redirect`
**`amp_wp_filter_config_list`**
Extend the list of post types, taxonomies, and conditions where AMP is disabled site-wide.
Parameter: `(array) $filters`
= URL and Permalink Filters =
**`amp_wp_pre_get_permalink`**
Short-circuit AMP permalink generation. Return any non-false value to bypass the core URL builder.
Parameters: `(mixed) $pre` (default false), `(int) $post_id`
**`amp_wp_get_permalink`**
Filter the final AMP URL after it has been built.
Parameters: `(string) $amp_url`, `(int) $post_id`
**`amp_wp_url_format_filter`**
Change the AMP URL format. Accepted values: `start-point` (prefix, e.g. `/amp/slug`) or `end-point` (suffix, e.g. `/slug/amp`).
Parameter: `(string) $format`
**`amp_wp_url_excluded`**
Add URL paths that must never serve an AMP version.
Parameter: `(array) $excluded_urls`
**`amp_wp_transformer_exclude_subdir`**
Add path segments that the AMP URL transformer should skip when rewriting internal links. Used internally by AMP WP for WPML and Polylang language prefixes.
Parameter: `(array) $exclude_dirs`
= Structured Data Filters (JSON-LD) =
All JSON-LD filters are active only when "Enable Structured Data on Site" is on in AMP WP Settings. The three schema-data filters carry a trailing underscore. This is generated internally via `sprintf( 'amp_wp_json_ld_%s_', $type )` and the underscore must be part of the hook name you register.
**`amp_wp_json_ld_config`**
Filters the generator configuration before any schema is built.
Parameter: `(array) $config` with keys:
* `active` (bool): set `false` to disable the entire JSON-LD generator for the current request.
* `logo` (string): Organization logo URL. When non-empty, an `Organization` block is emitted on every page and all Article-type schemas reference it by `@id`.
* `posts_type` (string): Fallback schema type when `schema_type_for_post` is empty. Default `BlogPosting`.
* `media_field_id` (string): Post meta key for audio/video URL in format posts. Default `_featured_embed_code`.
AMP WP core attaches at priority 15 to inject the branding logo. Use priority 20 or higher to override it.
`add_filter( 'amp_wp_json_ld_config', function( $config ) { ... }, 20 );`
**`amp_wp_json_ld_organization_`**
Filters the `Organization` schema array before output. Fires only when a logo is configured. Return `false` or an empty array to suppress the block.
Parameter: `(array) $data`
`add_filter( 'amp_wp_json_ld_organization_', function( $data ) { ... } );`
**`amp_wp_json_ld_website_`**
Filters the `WebSite` schema array before output. Fires only on the homepage and front page.
Parameter: `(array) $data`
`add_filter( 'amp_wp_json_ld_website_', function( $data ) { ... } );`
**`amp_wp_json_ld_single_`**
Filters the singular-content schema array before output. Fires on all singular pages: standard posts (Article, NewsArticle, BlogPosting), static pages (WebPage), WooCommerce products (Product), post format overrides (AudioObject, VideoObject, ImageObject), and custom post types.
Parameter: `(array) $data`
`add_filter( 'amp_wp_json_ld_single_', function( $data ) { ... } );`
= Content and Theme Filters =
**`amp_wp_template_page_on_front`**
Specify the page ID to use as the AMP front page when a static homepage is configured.
Parameter: `(int) $page_id`, default 0.
**`amp_wp_template_show_on_front`**
Control what displays on the AMP homepage. Accepted values: `posts` or `page`.
Parameter: `(string) $show_on_front`
**`amp_wp_template_active_template`**
Override the active template metadata array.
Parameter: `(array) $template_info`
**`amp_wp_template_set_menu_walker`**
Enable or disable the custom sidebar menu walker for a specific nav menu location.
Parameters: `(bool) $use_walker`, `(array) $args`
**`amp-wp-template-default-theme-mod`**
Set default values for AMP WP Customizer options.
Parameters: `(mixed) $default_value`, `(string) $option_key`
**`amp_wp_home_featured`**
Customize the `WP_Query` arguments used to fetch posts for the homepage featured slider.
Parameter: `(array) $query_args`
**`amp_wp_get_template`**
Override the file path used to locate a template part.
Parameters: `(string) $located`, `(string) $file`, `(array) $args`, `(string) $template_path`, `(string) $default_path`
**`amp_wp_html_dom_filter_attributes`**
Filter an HTML element's attributes during the DOM processing pipeline.
Parameters: `(array) $attributes`, `(string) $tag_name`, `(array) $valid_attributes`
**`amp_wp_style_files_{$file}`**
Filter CSS file content before it is added to the inline `