qTranslate-Team / qtranslate-x

Wordpress plugin: Adds user-friendly and database-friendly multilingual content management and translation support.
http://qtranslatexteam.wordpress.com/about/
GNU General Public License v3.0
206 stars 149 forks source link

Custom query with current language #527

Open nhantam opened 7 years ago

nhantam commented 7 years ago

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 7 years ago

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.