该插件尚未通过WordPress的最新3个主要版本进行测试。 当与较新版本的WordPress一起使用时,可能不再受到维护或支持,并且可能会存在兼容性问题。

AMP Related Posts

描述

Adds recent posts to your AMP content. Extends the AMP plugin (Automattic) via options page, works alongside all other AMP plugins by use of shortcode added to the plugins template. Shortcode allows to customize the endpoint of the links (to fit the AMP plugin you are using), add a title, and set a limit to the total amount of links.

NEW IN 2.0

If you make use of the popular AMP plugin by Automattic you can now use of the new options page! The plugin uses the AMP footer hook to add Recent Posts to your AMP content and comes with a series of new functions:

  • Post type support: return posts, pages or any other including custom post type

  • Display featured images

  • Display the date

  • Exclude posts by ID

  • Change the priority of the hook

As well the default options of setting a custom endpoint, heading and max number of posts.

With the 2.0 update we completely rewritten the plugin (better queries, better compatibility, bug fixes) with you in mind. Although we’ve tested
extensively something might have slipped through, kindly let us know if you find any
inconsistencies, thank you!

This plugin is actively maintained but will not be supported. I will however try to answer any questions in the comment section of the plugin website and create a FAQ here in the repository.

屏幕截图

  • Rendering of plugin including featured image and date
  • Rendering of plugin including date
  • Plugin options page

安装

Using the AMP plugin by Automattic

  1. Upload and activate plugin
  2. Visit the plugin options page and set your preferences!

Using shortcode

  1. Upload and activate plugin
  2. Place this code in your AMP template:

<?php echo do_shortcode( "[amp-related-posts]" ); ?>

Shortcode: Customizing the display of the AMP Related Posts plugin:

  • append=’amp’ change the endpoint to suit your own. Depending on which AMP plugin you are using you can adjust the slug to direct to the AMP articles, standard: ‘amp’ (appropriate for the AMP plugin by Automattic).

Example: append=’amp-post’ will generate a slug ‘yourwebsite.nl/post/amp-post/’

  • heading=’Related Posts’ will add an H3 heading, standard: none

  • max=’5′ will set a limit to the amount of posts displayed:, standard: 10

  • The code can now look like this:

<?php echo do_shortcode( "[amp-related-posts append='amp' heading='Related Posts' max='5']" ); ?>

Depreciated and backwards compatibility

If you are using the AMP plugin by Automattic you might have used a custom hook to implement the code in your theme’s functions.php file. Since the 2.0 update this can now be handled by the plugin setting on the options page. If you wish to keep using the hook please update it like so:

//* Add content to the AMP template footer (AMP plugin Automattic)
//* Place in your theme's functions.php



function add_rel_to_amp_footer() {

if ( function_exists('is_amp_endpoint') )
?>



<?php echo do_shortcode( "[amp-related-posts append='amp' heading='Related Posts' max='5']" ); ?> 

<?php

}


add_action( 'amp_post_template_footer', 'add_rel_to_amp_footer', 3 );

常见问题

None yet.None yet.

评价

2019年1月6日
Following the instructions within the plugin (printed onscreen when you install the plugin) prints the shortcode to the screen. The install instructions here on Wordpress.org is correct, but not within the plugin itself. I discovered that the shortcode needed to be changed [amp_related_posts]. I presume the plugin was renamed at some point. Despite this fix, there were a few issues: There's still an error printed to the screen. Something about expecting a 4th param. The plugin ignored any settings added to the plugin settings interface. There was no featured image and the plugin printed 5 related posts instead of the 3 I set it to. I'm not going to spend my time trying to resolve the issues. It needs a little work before it's ready for prime-time. For now I'll look for another solution.
2017年1月14日
Easy to setup, good customizability and super friendly developer!
2016年11月11日 1 回复
Works great! I wish it gave more options on how to handle image cropping, maybe in a future:)
阅读所有6条评价

贡献者及开发者

“AMP Related Posts” 是开源软件。 以下人员对此插件做出了贡献。

贡献者

将“AMP Related Posts”翻译成您的语言。

对开发感兴趣吗?

您可以浏览代码,查看SVN仓库,或通过RSS订阅开发日志

更新日志

1.0

Release date: July 4th, 2016

1.1

Release date: October 10th, 2016

  • Updated installation tips to new version AMP plugin

2.0

Release date: November 9th, 2016

  • Rewritten plugin with better queries
  • Added functions post type support, featured images, display date, exclude posts and set hook priority for users of the AMP plugin by Automattic
  • Various compatibility improvements
  • Small changes in CSS for better compatibility with our other plugins
  • Various small bug fixes

2.1.1

Release date: December 20th, 2016

  • Updated WP 4.7