How To Write An Inner Join With WP Query

Ok so the way I was able to just show English properties on the user admin page was with this posts_request hook: add_filter(‘posts_request’, function($sql, $query) { $is_user_edit_page = ( isset($_SERVER[‘HTTP_REFERER’]) && strpos($_SERVER[‘HTTP_REFERER’], ‘user-edit’) !== false ); $is_property_sql = (strpos($sql, ‘property’) !== false); if ($is_user_edit_page && $is_property_sql) { $sql = str_replace(“‘sp'”, “‘en'”, $sql); } return $sql; … Read more

Need to give custom page template for each language in WPML

You can accomplish different sidebar content per language with either the plugin Widget Logic, or with the Dynamic Widgets plugin Alternatively you can make different sidebar templates per language and use a conditional on the language: if(ICL_LANGUAGE_CODE==’en’){ get_sidebar(‘en’); } if(ICL_LANGUAGE_CODE==’fr’){ get_sidebar(‘fr’); }

Remove WPML’s home_url filter

I found that it required removing 4 filters/actions to undo WPML’s home_url modification. Since I didn’t know what else this might break, I ended up changing my site’s logo to use site_url() which in my case was the same, but not changed by WPML. function disable_things(){ remove_filter( ‘page_link’, array( $this, ‘permalink_filter’ ), 1, 2 ); … Read more

WPML : how to determine manually the language in which a given page is displayed

WPML defines constants that you can use go get the current language: ICL_LANGUAGE_CODE – current language code (eg: en,fr,sp). ICL_LANGUAGE_NAME_EN – Name of the current language in English (eg: English, French. Spanish). ICL_LANGUAGE_NAME – Name of current language, in the current language (eg: English, Français, Español).

WPML Get url without outputting

Actually WordPress lacks a real function to get posts by slug/post-name. But you can use get_page_by_path() for it so you don’t have to use a custom query: if(function_exists(‘icl_object_id’)) { $post = get_page_by_path(‘your-slug’); $id = icl_object_id($post->ID,’post’,true); $link = get_permalink($id); } The only difference here is that you must use the full path i.e. (‘parent-page/sub-page’) if you … Read more

How to get posts in different language from WPML Plugin [closed]

Assuming $new_lang holds the desired two letter language code (e.g. ‘fr’), you can do this: global $sitepress; $current_lang = $sitepress->get_current_language(); //save current language $sitepress->switch_lang($new_lang); //…run query here; if you use WP_Query or get_posts make sure you set suppress_filters=0 … $sitepress->switch_lang($current_lang); //restore previous language For more info, check http://wpml.org/documentation/support/achieving-wpml-compatibility-for-your-themes-and-plugins/debugging-theme-compatibility/

Rewrite url for custom post type

this will not work: ‘en/index.php?post_type=vinos’ there is no en/index.php, it has to be: ‘index.php?post_type=vinos’ if you need to detect en in the path, add a query var, then set that query var in your rewrite: function wpa_query_vars( $qvars ) { $qvars[] = ‘wpa_lang’; return $qvars; } add_filter( ‘query_vars’, ‘wpa_query_vars’ ); then in your rewrite rule: … Read more