Title: [Plugin: Ambrosite Next/Previous Post Link Plus] WPML Patch
Last modified: August 20, 2016

---

# [Plugin: Ambrosite Next/Previous Post Link Plus] WPML Patch

 *  Resolved [greencode](https://wordpress.org/support/users/greencode/)
 * (@greencode)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-ambrosite-nextprevious-post-link-plus-wpml-patch/)
 * I’m using the patch that you posted on [http://www.ambrosite.com/plugins/next-previous-post-link-plus-for-wordpress](http://www.ambrosite.com/plugins/next-previous-post-link-plus-for-wordpress)
 * But I get the following error (I’d imagine it’s because I’m not adding it to 
   the correct place!)
 *     ```
       Parse error: syntax error, unexpected T_FUNCTION, expecting T_WHILE in /home/mysite/public_html/dev/acf/wp-content/plugins/ambrosite-nextprevious-post-link-plus/ambrosite-post-link-plus.php on line 225z
       ```
   
 * I replaced this code (on line 204 of version 2.4)
 *     ```
       $result = $wpdb->get_results("SELECT DISTINCT p.* FROM $wpdb->posts AS p $join $where $sort");
       ```
   
 * with this code
 *     ```
       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");
       ```
   
 * Any ideas?
 * [http://wordpress.org/extend/plugins/ambrosite-nextprevious-post-link-plus/](http://wordpress.org/extend/plugins/ambrosite-nextprevious-post-link-plus/)

Viewing 15 replies - 1 through 15 (of 21 total)

1 [2](https://wordpress.org/support/topic/plugin-ambrosite-nextprevious-post-link-plus-wpml-patch/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-ambrosite-nextprevious-post-link-plus-wpml-patch/page/2/?output_format=md)

 *  Plugin Author [ambrosite](https://wordpress.org/support/users/ambrosite/)
 * (@ambrosite)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-ambrosite-nextprevious-post-link-plus-wpml-patch/#post-3093233)
 * 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.
 *  Thread Starter [greencode](https://wordpress.org/support/users/greencode/)
 * (@greencode)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-ambrosite-nextprevious-post-link-plus-wpml-patch/#post-3093234)
 * Apologies. Could you add the code how it should be. Not sure where the } needs
   to go.
 * Thanks.
 *  Plugin Author [ambrosite](https://wordpress.org/support/users/ambrosite/)
 * (@ambrosite)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-ambrosite-nextprevious-post-link-plus-wpml-patch/#post-3093239)
 * 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");
       }
       ```
   
 *  Thread Starter [greencode](https://wordpress.org/support/users/greencode/)
 * (@greencode)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-ambrosite-nextprevious-post-link-plus-wpml-patch/#post-3093249)
 * 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?
 *  Plugin Author [ambrosite](https://wordpress.org/support/users/ambrosite/)
 * (@ambrosite)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-ambrosite-nextprevious-post-link-plus-wpml-patch/#post-3093254)
 * 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.
 *  Thread Starter [greencode](https://wordpress.org/support/users/greencode/)
 * (@greencode)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-ambrosite-nextprevious-post-link-plus-wpml-patch/#post-3093255)
 * Okay, thanks. I will do. If I get any results I’ll let you know.
 *  [Ryan Riatno](https://wordpress.org/support/users/ponzicrawl/)
 * (@ponzicrawl)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-ambrosite-nextprevious-post-link-plus-wpml-patch/#post-3093334)
 * Hi, any updates on this? I’m experiencing the same problem…
 *  Thread Starter [greencode](https://wordpress.org/support/users/greencode/)
 * (@greencode)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-ambrosite-nextprevious-post-link-plus-wpml-patch/#post-3093335)
 * 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?
 *  [Ryan Riatno](https://wordpress.org/support/users/ponzicrawl/)
 * (@ponzicrawl)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-ambrosite-nextprevious-post-link-plus-wpml-patch/#post-3093339)
 * I use custom field as a parameter, the next link in foreign language is wrong
   its pointing to the main language.
 *  [Maxatomik](https://wordpress.org/support/users/maxatomik/)
 * (@maxatomik)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/plugin-ambrosite-nextprevious-post-link-plus-wpml-patch/#post-3093396)
 * 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 🙂
 *  [Pieter Bos](https://wordpress.org/support/users/senlin/)
 * (@senlin)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/plugin-ambrosite-nextprevious-post-link-plus-wpml-patch/#post-3093425)
 * 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
 *  Thread Starter [greencode](https://wordpress.org/support/users/greencode/)
 * (@greencode)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/plugin-ambrosite-nextprevious-post-link-plus-wpml-patch/#post-3093427)
 * [@piet](https://wordpress.org/support/users/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](https://wordpress.org/support/users/maxatomik/)’s code
   as that seems to work for me.
 *  [Pieter Bos](https://wordpress.org/support/users/senlin/)
 * (@senlin)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/plugin-ambrosite-nextprevious-post-link-plus-wpml-patch/#post-3093428)
 * [@greencode](https://wordpress.org/support/users/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.
 *  Thread Starter [greencode](https://wordpress.org/support/users/greencode/)
 * (@greencode)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/plugin-ambrosite-nextprevious-post-link-plus-wpml-patch/#post-3093429)
 * 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.
 *  Plugin Author [ambrosite](https://wordpress.org/support/users/ambrosite/)
 * (@ambrosite)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/plugin-ambrosite-nextprevious-post-link-plus-wpml-patch/#post-3093430)
 * 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.

Viewing 15 replies - 1 through 15 (of 21 total)

1 [2](https://wordpress.org/support/topic/plugin-ambrosite-nextprevious-post-link-plus-wpml-patch/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-ambrosite-nextprevious-post-link-plus-wpml-patch/page/2/?output_format=md)

The topic ‘[Plugin: Ambrosite Next/Previous Post Link Plus] WPML Patch’ is closed
to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/ambrosite-nextprevious-post-link-
   plus.svg)
 * [Ambrosite Next/Previous Post Link Plus](https://wordpress.org/plugins/ambrosite-nextprevious-post-link-plus/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ambrosite-nextprevious-post-link-plus/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ambrosite-nextprevious-post-link-plus/)
 * [Active Topics](https://wordpress.org/support/plugin/ambrosite-nextprevious-post-link-plus/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ambrosite-nextprevious-post-link-plus/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ambrosite-nextprevious-post-link-plus/reviews/)

 * 21 replies
 * 5 participants
 * Last reply from: [ambrosite](https://wordpress.org/support/users/ambrosite/)
 * Last activity: [12 years, 8 months ago](https://wordpress.org/support/topic/plugin-ambrosite-nextprevious-post-link-plus-wpml-patch/page/2/#post-3093436)
 * Status: resolved