helick / related-posts
The Helick related posts plugin
Installs: 139
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 1
Type:wordpress-plugin
Requires
- php: >=7.1
- composer/installers: ^1.6
- helick/contracts: ^1.1
- htmlburger/carbon-fields: ^3.1
- wp-cli/wp-cli: ^2.2
Requires (Dev)
This package is auto-updated.
Last update: 2024-10-29 06:05:33 UTC
README
The plugin provides a simple related posts functionality with the following features:
- Ability to manually override related posts
- ElasticPress integration
Requirements
Make sure all dependencies have been installed before moving on:
Install
Via Composer:
$ composer require helick/related-posts
Usage
The plugin exposes a single function that returns a list of post IDs.
$postIds = Helick\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 post_types: 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
WP_Term
objects, results will match these terms - array terms_not_in: array of
WP_Term
objects, results will not match these terms - bool ep_integrate: if true then ElasticPress is used to get the results, defaults to
defined('EP_VERSION')
Custom post type support
Control supported post types:
add_filter('helick_related_posts_supported_post_types', function (array $postTypes) { $postTypes[] = 'your-custom-post-type'; return $postTypes; });
Control associated post types:
add_filter('helick_related_posts_associated_post_types', function (array $postTypes) { $postTypes[] = 'your-custom-post-type'; return $postTypes; });
Contributing
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
Security
If you discover any security related issues, please email evgenii@helick.io instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.