special query (gengo wordpress) with inner join
-
Hello, I would like to make a special query in WordPress.
I would like my function gengoGetAPost to find (if exists) the translated post of a given post_id.
Posts are in the “$wpdb->posts” table.
Posts with their post_id, language_id and translation_group are in “$gengo->post2lang_table”.If I have 2 posts :
|POST_ID|LANGUAGE ID|TRANSLATION_GROUP| 17 1 5 23 2 5
I would like that gengoGetAPost(17,2) returns me the row of the post #23 in the $wpdb->posts table.
Could you help me ?
Here’s my first draft (not working), but I don’t know what to do now…function gengoGetAPost($post,$lang) { global $gengo, $wpdb; $language_ids = 2; $query = "SELECT p.* FROM $wpdb->posts AS p INNER JOIN $gengo->post2lang_table AS p2l ON p.ID = p2l.post_id WHERE p2l.translation_group=$lang AND p2l.post_id='".$post."' LIMIT 1"; echo $query; return ($result = $wpdb->get_row($query)) ? $result : NULL; }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘special query (gengo wordpress) with inner join’ is closed to new replies.