1

I'm using WPML and need a custom search query (The default search of wordpress is not working in my case). Let say my query is: "SELECT * FROM wp_posts WHERE post_title LIKE %s% AND [WPML_CURRENT_LANGUAGE_CONDITION]";

Please help me check which table I should care for this.

Thanks!

O. Jones
  • 103,626
  • 17
  • 118
  • 172
mrdeeds88
  • 115
  • 1
  • 7

1 Answers1

5

After checking with my friend, he helped me out and this query is find post in current language only.

$sql = "SELECT * FROM wp_posts
INNER JOIN wp_icl_translations post_trans
ON wp_posts.ID = post_trans.element_id
WHERE [...YOUR CONDITIONS]
AND post_trans.language_code = '". ICL_LANGUAGE_CODE ."'";
Tyler2P
  • 2,324
  • 26
  • 22
  • 31
mrdeeds88
  • 115
  • 1
  • 7