1

How to write query for getting child post id of the parent post from a different table in Wordpress?

I have many custom post types in Wordpress, Each post type have many child post type Like this:

California School > Video 1 , Video 4 , Video 7

{School and Video are custom post types}

I have a table like this:

Table name is kg_toolset_associations

(This table created by Toolset plugin.)

I'd like to get the ID of all videos that associates to parent school;

I wrote this query :

<?php
global $wpdb;
$results = $wpdb->get_results( "SELECT `child_id`  FROM `kg_toolset_associations` WHERE `relationship_id` = `4` AND `parent_id` = `8568`, OBJECT );
?>
Chris Schaller
  • 13,704
  • 3
  • 43
  • 81
  • Table and column names in mysql should either be enclosed in backticks or not at all. Single quotes produces something very different (or just an error). – Nigel Ren Sep 06 '20 at 08:25

0 Answers0