This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 2 replies, has 2 voices.

Last updated by francescoG-4 5 years ago.

Assigned support staff: Denise.

Author Posts
June 18, 2014 at 8:55 am #421002


Dear Support,

I am developing a plugin using custom types and I am facing a problem with the front-end.
The front-end shows all results for both languages (en, de). This is the query I use for the shortcode part, could you help me to fix this problem please?

$show_articles = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->posts
    											LEFT JOIN $wpdb->postmeta value ON ($wpdb->posts.ID = value.post_id)
    											WHERE $wpdb->posts.post_type = 'articles' 
    											AND $wpdb->posts.post_status = 'publish' 
    											AND value.meta_key = 'on_homepage'
    											AND value.meta_value = 'on'
    											ORDER BY id DESC LIMIT 0, 30"));
    foreach($show_articles as $sw) {
    <?php echo $sw->post_title; 
    if ( has_post_thumbnail($sw->ID) ) {
	echo get_the_post_thumbnail($sw->ID);
    <a href="<?php echo get_permalink($sw->ID); ?>" type="button">Show</a>


June 18, 2014 at 2:14 pm #421281


Hi Francesco,

In order to display posts in the current language WPML applies filters to WordPress queries but, and this is the important point here, only if the WordPress query allows filters to be applied.

A WordPress query will allow plugins like WPML to apply filters if it has the 'suppress_filters' => false parameter set.

You will want to use query_posts if you are altering the main loop:
if you are creating a secondary loop create a new instance of WP_Query:

Do not use get_posts because get_posts uses 'suppress_filters' => true as default see:

If you want to reiterate through the query results and filter based on language you can always try this:


Let me know if the above makes sense and if anything is unclear please do not hesitate to let me know.


June 18, 2014 at 5:35 pm #421422


Hello Denise,

I forgot that $wpdb bypasses all filters, including WPML's language filters.
I removed the query and used get_posts() specifing "'suppress_filters' => false", and everything is working fine now.