Skip Navigation

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 4 replies, has 2 voices.

Last updated by barbaraF-3 6 years, 3 months ago.

Assigned support staff: Dat Hoang.

Author Posts
July 15, 2015 at 7:15 am #659459



I am making queries like

$total_post = $wpdb->get_results("
SELECT * FROM wp_posts LEFT JOIN wp_postmeta ON(wp_posts.ID = wp_postmeta.post_id) LEFT JOIN wp_term_relationships ON(wp_posts.ID = wp_term_relationships.object_id) LEFT JOIN wp_term_taxonomy ON(wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id) WHERE (wp_postmeta.meta_key = '".$soud."' or wp_postmeta.meta_key = '".$_REQUEST['sound']."' ) AND wp_postmeta.meta_value = '".$_REQUEST['sound_val']."'
AND $wpdb->posts.post_status = 'publish'
AND $wpdb->posts.post_type = 'product'
group by wp_posts.ID

but it is showing results for all language.

1) This code is inside of a template.
2) Called via AJAX
3) The target url which is echoing the data has a en and pt version, both echo all the results.


July 16, 2015 at 8:33 am #660427

Dat Hoang

I'm sorry that we do not support for this kind of custom request.

As I see your query may use WP_Query to get the content.
With this, WPML supports very well.

The example code:

	global $sitepress;
	$cur_lang = $sitepress->get_current_language();
	$new_lang = 'en'; // change language code you want here. 
	* Do WP_Query here
July 16, 2015 at 9:41 am #660493


How is this custom?
I am asking which table/column you're storing English language entries in.

July 16, 2015 at 10:19 am #660536

Dat Hoang

Great to hear that you have the way to resolve this.

However, in your question, you don't ask anything for this "which table/column you're storing English language entries in."

FYI, in the case you still need this info:

July 17, 2015 at 9:41 am #661352


Please read the title of this topic again. "Make SQL queries for a specific language." Now I am not a genius but don't know of any other way to make sql queries besides querying a table/column.

You could have just said that instead of posting 'we do not support for this kind of custom request'