Get reverse-related posts
Parameter | Required | Type | Notes |
---|---|---|---|
$post_id | Y | int | The original post ID |
$options[‘post_type’] | N | mixed | Find related posts by post type(s). Accepts a string or array. |
$options[‘field_name’] | N | mixed | Find related posts by field name(s). Accepts a string or array. |
$options[‘field_type’] | N | mixed | Find related posts by field type(s). Accepts a string or array (default = ‘relationship’). |
$options[‘post_status’] | N | mixed | Find related posts by post status(es). Accepts a string or array. |
Return Value
(array) Related post IDs
Examples
News items have a “related_events” relationship field. To display related news on an event page:
Retrieve items from a specific post type