• Resolved serban

    (@serban)


    I have installed WP 3.3.1 with a child theme of Twentyeleven, Theme Extensions plugin (for Twentyeleven theme) and Polylang v.0.6 .
    While having just 2 posts for each language, I found an error log on the server (shared hosting) showing a MySQL error:

    WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ON object_id = ID WHERE post_type = 'post' AND post_status = 'publish' AND term_' at line 1 for query SELECT YEAR(post_date) ASyear, MONTH(post_date) ASmonth, count(ID) as posts FROM wp_posts INNER JOIN ON object_id = ID WHERE post_type = 'post' AND post_status = 'publish' AND term_taxonomy_id = 3 GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC made by require, require_once, include, get_sidebar, locate_template, load_template, require_once, dynamic_sidebar, call_user_func_array, WP_Widget->display_callback, WP_Widget_Archives->widget, wp_get_archives

    So, I have searching into the code and I found a missing globalize of the class $wpdb around the line 432, file core.php (/polylang/include/core.php).
    To fix the problem I have added a line
    global $wpdb;
    just before this line
    return $sql . $GLOBALS['wpdb']->prepare(" INNER JOIN $wpdb->term_relationships ON object_id = ID");
    so the complete code of this function is now:

    // modifies the sql request for wp_get_archives an get_adjacent_post to filter by the current language
    	function posts_join($sql) {
                    global $wpdb;
    		return $sql .  $GLOBALS['wpdb']->prepare(" INNER JOIN $wpdb->term_relationships ON object_id = ID");
    	}

    Maybe it helps…

    https://www.ads-software.com/extend/plugins/polylang/

Viewing 1 replies (of 1 total)
  • Plugin Author Chouby

    (@chouby)

    Thank you very much !

    I was already aware of this as this is the solution for a bug (archives widget not working) reported some days ago. But don’t misinterpret my words, this kind of help is very much appreciated ??

    The correction will be included in v0.6.1 coming soon…

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Polylang] (fix for) adjacent post function not working with v.0.6’ is closed to new replies.