HM Related Posts
Related Posts (from HM Core) + Meta box for manually overriding dynamic selected posts.
by Human Made Limited · github.com/humanmade/hm-related-posts
★ 12stars
4.2kcomposer installs
2forks
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/humanmade/hm-related-posts/archive/refs/heads/master.zipAlso on Packagist as humanmade/related-posts:
composer require humanmade/related-postsFrom the readme
Related Posts
This plugin provides a simple related posts function with the following features:
ElasticPress integration (uses a "More Like This" query)
Admin UI for manually overriding related posts
Installation
Usage
The plugin exposes a single function that returns a list of post IDs.
HM\RelatedPosts\get( int $postid, array $args = [] )
$postid is the ID of the post to get related content for.
$args allows you some control over the posts that are returned:
- int limit: defaults to 10
- array posttypes: array of post types to limit results to. Defaults to [ 'post' ]
- array taxonomies: array of taxonomies to compare against. Defaults to [ 'category' ]
- array terms: array of WPTerm objects, results will match these terms
- array termsnotin: array of WPTerm objects, results will not match these terms
- bool epintegrate: if true then ElasticPress is used to get the results, Defaults to defined( 'EPVERSION' )
Custom post type support
To add related posts support to your custom post type simply declare the following:
addposttypesupport( 'your-custom-post-type', 'hm-related-posts' );
In addition to fine control the post types that have related posts support you can use
Read the full README on GitHub →