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


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


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


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

Top ↑

Return Return


Top ↑

Source Source

File: includes/

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

		global $wpdb;
		return $wpdb->get_col(
				"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",
		); // db-call ok; no-cache ok.


Top ↑

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.