qtranslate / qtranslate-xt

qTranslate-XT (eXTended) - reviving qTranslate-X multilingual plugin for WordPress. A new community-driven plugin soon. Built-in modules for WooCommerce, ACF, slugs and others.
GNU General Public License v2.0
545 stars 103 forks source link

Custom query with current language #527

Open herrvigg opened 6 years ago

herrvigg commented 6 years ago

Issue by nhantam Tuesday Jul 25, 2017 at 02:40 GMT Originally opened as https://github.com/qTranslate-Team/qtranslate-x/issues/527


My website have 2 language. I have custom query. How do I get post if current language available ?

$args = array( 'post_type' => 'wpdmpro', 'posts_per_page'=> 10, 'paged' => $paged, 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => 'wpdmcategory', 'field' => 'id', 'terms' => $category_id, ) ) );

query_posts($args);

Thanks & Regards

herrvigg commented 6 years ago

Comment by herrvigg Wednesday Aug 30, 2017 at 17:23 GMT


What do you mean by "if current language available" ? qTranslate-X adds a hook called "qtranxf_postsFilter" on "the_posts" filter and translates stuff from this. If you have other criterions you could also manage them with meta fields. You can also check the qtranxf_where_clause_translated_posts and maybe customize some filter there.