Related_Posts
in package
Handle the related posts frontend functionality.. - Given a post ID, return an array of related post IDs.
These related IDs are determined by shared categories and tags, with a preference for posts that share both.
- The related post IDs are stored as an array in the post metadata on the target post.
Tags
Table of Contents
Constants
- META_KEY = 'pnet_related_posts'
- Meta key name.
Properties
- $common_related_posts : Related_Posts
- The instance of the Common_Related_Posts class.
- $instances : array<string|int, object>
- The array of instances of this class and sub-classes.
Methods
- get_ids() : array<string|int, int>
- Return the array of related post ids for the target post.
- get_instance() : object
- Creates and/or returns the instance of this class.
- __construct() : void
- Initialise the class.
Constants
META_KEY
Meta key name.
protected
string
META_KEY
= 'pnet_related_posts'
Tags
Properties
$common_related_posts
The instance of the Common_Related_Posts class.
protected
Related_Posts
$common_related_posts
Tags
$instances
The array of instances of this class and sub-classes.
protected
static array<string|int, object>
$instances
= array()
Tags
Methods
get_ids()
Return the array of related post ids for the target post.
public
get_ids(int $post_id) : array<string|int, int>
Parameters
- $post_id : int
-
The id of the post to retrieve related posts for.
Tags
Return values
array<string|int, int> —Related post ids.
get_instance()
Creates and/or returns the instance of this class.
public
static get_instance() : object
Tags
Return values
object —The instance of this class.
__construct()
Initialise the class.
protected
__construct() : void