PLL breaks get_next_post / get_previous_post for CPT with disabled translation
-
Hi there,
Thank you for your work on this amazing plugin.
I’m using WP 4.4.2 and Polylang 1.8.5, with a static Front Page and no custom permalinks structure.
I’m pretty sure there is a bug in the plugin, causing WP pagination functions get_next_post() , get_previous_post() and get_adjacent_post() return empty result when translation is disabled for the current Post Type in Polylang settings.
In file frontend/frontend-filters.php line 31-36 :
// rewrites archives, next and previous post links to filter them by language foreach ( array( 'getarchives', 'get_previous_post', 'get_next_post' ) as $filter ) { foreach ( array( '_join', '_where' ) as $clause ) { add_filter( $filter.$clause, array( &$this, 'posts'.$clause ) ); } }
This code adds an INNER JOIN clause to the SQL query used by WordPress (see the apply_filters in wp-includes/link-template.php line 1669) when searching adjacent post.
I understand the purpose of your code is to filter the adjacent post by language. Problem is that the INNER JOIN clause is added, even if the translation of this CPT is disabled in PLL settings. It cause the SQL query to return empty results because your join clause ‘pll_tr.object_id = ID’ can never be true.
I think wp_get_archives() may also be broken in the same context, but I didn’t test it.
Can you confirm the issue ? I hope you can solve it in next release, but I know PLL is a lot of work.
Bests regards,
Pierre Dargham
- The topic ‘PLL breaks get_next_post / get_previous_post for CPT with disabled translation’ is closed to new replies.