-
Notifications
You must be signed in to change notification settings - Fork 383
Commenting
When using "Native AMP" or "Paired Mode," WordPress commenting will work on AMP-enabled pages (screencast, example page).
add_theme_support( 'amp' )
will enable standard commenting behaviour; submit comment, reload page after submission.
There is no special code/markup required for this functionality. It's all out of the box.
By setting the comments_live_list
parameter to true, you'll enable the ability to enhance the native WordPress commenting into a live updating system. see: Adding Theme Support
This removes the need for a page reload and will update based on new comments being posted in the background.
There is, however, a requirement in the code and markup of the theme to enable this further.
In the comments.php
file, you'll need to wrap up wp_list_comments() call in an <amp-live-list>
.
Minimal amp-live-list
requirements:
/**
* Comments.php
*/
?>
<amp-live-list id="amp-live-comments-list-<?php the_ID(); ?>" data-max-items-per-page="10000">
<ol items class="comments__list">
<?php
wp_list_comments( array(
'style' => 'ol',
'short_ping' => true,
) );
?>
</ol><!-- .comment-list -->
<div update class="live-list__button">
<button class="button" on="tap:amp-live-comments-list-<?php the_ID(); ?>.update">
<?php esc_html_e( 'New comment(s)', 'ampconf' ); ?>
</button>
</div>
<nav pagination>
<?php the_comments_navigation(); ?>
</nav>
</amp-live-list>
For a more complete example see comments.php
Notice: Please also see the plugin documentation on amp-wp.org