Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

LLMS_Post_Relationships::get_related_posts( int $post_id, string $post_type, string $meta_key )

Retrieve an array of post ids related to the deleted post by post type and meta key.


Parameters Parameters

$post_id

(int) (Required) WP Post ID of the deleted post.

$post_type

(string) (Required) WP Post type of the related post(s).

$meta_key

(string) (Required) meta_key to check for relations by.


Top ↑

Return Return

(array)


Top ↑

Source Source

File: includes/class.llms.post.relationships.php

	private function get_related_posts( $post_id, $post_type, $meta_key ) {

		global $wpdb;
		return $wpdb->get_col(
			$wpdb->prepare(
				"SELECT p.ID
			 FROM {$wpdb->posts} AS p
			 LEFT JOIN {$wpdb->postmeta} AS pm
			        ON p.ID = pm.post_id
			       AND pm.meta_key = %s
			 WHERE p.post_type = %s
			   AND pm.meta_value = %d",
				$meta_key,
				$post_type,
				$post_id
			)
		); // db-call ok; no-cache ok.

	}


Top ↑

Changelog Changelog

Changelog
Version Description
3.16.12 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.