You are missing the closing curly brace at the end of the else clause.
Errors like that are normally caused by missing braces or semicolons.
Apologies. Could you add the code how it should be. Not sure where the } needs to go.
Thanks.
Like this. You missed the last line when you copied the code off my site.
global $table_prefix;
if ( function_exists('icl_sitepress_activate') ) {
$result = $wpdb->get_results("SELECT DISTINCT p.* FROM $wpdb->posts AS p,{$table_prefix}icl_translations AS icl_translations $join $where
AND p.ID = icl_translations.element_id AND icl_translations.language_code = '" . ICL_LANGUAGE_CODE . "' $sort");
} else {
$result = $wpdb->get_results("SELECT DISTINCT p.* FROM $wpdb->posts AS p $join $where $sort");
}
Umm, replacing the code
$result = $wpdb->get_results("SELECT DISTINCT p.* FROM $wpdb->posts AS p $join $where $sort");
on line 204 with
global $table_prefix;
if ( function_exists('icl_sitepress_activate') ) {
$result = $wpdb->get_results("SELECT DISTINCT p.* FROM $wpdb->posts AS p,{$table_prefix}icl_translations AS icl_translations $join $where
AND p.ID = icl_translations.element_id AND icl_translations.language_code = '" . ICL_LANGUAGE_CODE . "' $sort");
} else {
$result = $wpdb->get_results("SELECT DISTINCT p.* FROM $wpdb->posts AS p $join $where $sort");
}
causes nothing to display in either default or foreign language.
I’m using this code to display the previous/next nav
<div class="nav-arrows-head">
<div class="nav-previous"><?php previous_post_link_plus( array('order_by' => 'menu_order', 'in_same_cat' => true, 'loop' => true, 'format' => '%link', 'link' => 'Previous') ); ?></div>
<div class="nav-next"><?php next_post_link_plus( array('order_by' => 'menu_order', 'in_same_cat' => true, 'loop' => true, 'format' => '%link', 'link' => 'Next') ); ?></div>
</div>
Any ideas?
All right, so we fixed the syntax error (first problem solved), but now you are not getting any query results (new problem).
It is possible that something changed in a recent version of WPML that caused the patch to stop working. But if that is the case, I have no solution for it at the moment. The patch was provided to me by a WPML user. It would be best to pose this question to WPML support.
Okay, thanks. I will do. If I get any results I’ll let you know.
Hi, any updates on this? I’m experiencing the same problem…
Sorry, I’ve not looked at this since I last posted as the client doesn’t require multilingual functionality just yet.
Is the problem that you are getting that the previous/next just cycle through all posts and not just those in the selected category?
I use custom field as a parameter, the next link in foreign language is wrong its pointing to the main language.
Hi everyone,
here the patch i used with the last version of WPML and Ambrosite plugin :
// replace line 204 with the following code
global $table_prefix;
if ( function_exists('icl_sitepress_activate') ) {
$result = $wpdb->get_results("SELECT DISTINCT p.* FROM $wpdb->posts AS p JOIN {$table_prefix}icl_translations AS icl_translations ON icl_translations.element_id = p.ID $where AND p.ID = icl_translations.element_id AND icl_translations.language_code ='" . ICL_LANGUAGE_CODE . "' $sort");
} else {
$result = $wpdb->get_results("SELECT DISTINCT p.* FROM $wpdb->posts AS p $join $where $sort");
}
Its an update from de the code above…worked for me 🙂
This fix doesn’t work anymore with the latest versions of everything, at the time of writing:
WP 3.6
WPML 2.9.1
Ambrosite 2.4
@piet: I’m using 3.5.1, Ambrosite 2.4 and WPML 2.7.1 so obviously these are not the latest versions but have you tried using @maxatomik’s code as that seems to work for me.
@greencode, the fix stopped working after upgrading to WP 3.6/WPML 2.9.1
I can confirm that before that the fix worked brilliant.
But I cannot afford to run my code on anything lower than the latest, so that is why I posted that with the latest of everything the fix stopped working.
Let’s hope that this get’s resolved pretty quickly as I really need to update my versions of WPML and WP but am now slightly reluctant in doing so until this is resolved as the site relies on this working.
Has anyone tested whether the same problem exists with the core next/previous link functions? This would be incredibly easy to test and would only take five minutes — just replace next_post_link_plus with next_post_link and check the results.
If WPML does work with the core functions, then that probably means there is a filter somewhere in the WPML code that makes it work. If that were the case, it should be a fairly simple matter to copy that filter and adapt it to my plugin.