0

I'm trying to translate this

$loop = new WP_Query(array(
    'post_type' => 'YOUR_CUSTOM_TYPE_SLUG',
    'lang' => 'en',    // use language slug in the query
    // 'lang'           => '',      // query posts in all languages
    'paged' => get_query_var('paged'),
    'posts_per_page' => 10,
    'post_status' => 'publish',
));

into a Custom Select Query. I tried

SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->posts, meta_value as meta_value_pl WHERE ($wpdb->posts.post_status = 'publish' AND $wpdb->posts.post_type = 'YOUR_CUSTOM_TYPE_SLUG')

But with no luck. Can someone help ? Thanks !

Noman
  • 4,088
  • 1
  • 21
  • 36
Rom
  • 109
  • 2
  • 13
  • Does your wp_query worked ? try debug with `var_dump($loop->request);` also polylang [docs](https://polylang.pro/doc/developpers-how-to/) would be much helpful, make sure your language is enable – Noman Mar 12 '18 at 10:56
  • Yes, my Custom Query work fine, it's just not filtering the language. I couldn't find any thing about Custom Select Query on the polylang doc, only the classic wp query that you can see there. – Rom Mar 13 '18 at 11:54
  • try with documented and then copy the polylang part and add it in your custom query – Noman Mar 13 '18 at 12:22
  • I'm sorry @Noman, I don't know what you mean by trying with documented. I tried with : " WHERE ($wpdb->posts.post_status = 'publish' AND $wpdb->posts.lang = 'nl')" but without success. If I don't filter by posts.lang, I have post in both languages, and if I do, I get nothing. I wonder how polylang flag the post language. – Rom Mar 14 '18 at 22:51

0 Answers0