We can embed Twitter posts in AMP in two ways:
1. Using AMP plugin for WordPress
This plugin is developed by ‘Automattic‘, the corporation behind WordPress.com. It provides an easy way to embed Social media posts to WordPress blog that is compatible with both web and AMP version.
To embed a Twitter post in your WordPress article, simply add the URL of the Twitter post in WordPress editor in a new line:
After publishing the article, you can see that it appears perfect for the web as well as the AMP version.
— AMP Project (@AMPhtml) July 13, 2017
You can view the AMP version of this article by clicking this link on a mobile device.
2. Without using the plugin
1. Include the amp-twitter component: Place this script in the above the closing of the <head> tag.
<script async custom-element="amp-twitter" src="https://cdn.ampproject.org/v0/amp-twitter-0.1.js"></script>
2. Now we can embed the twitter post by adding the below code to our template file.