﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc
20682	get_adjacent_post generates invalid query for custom post types that don't support categories	batmoo		"If a custom post type isn't registered against the category taxonomy, setting {{{$in_same_cat}}} results in an invalid query.

{{{
SELECT p.* FROM wp_posts AS p
INNER JOIN wp_term_relationships AS tr ON p.ID = tr.object_id
INNER JOIN wp_term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
AND tt.taxonomy = 'category'
AND tt.term_id IN ()
WHERE p.post_date > '2012-05-15 16:15:07'
AND p.post_type = 'book'
AND p.post_status = 'publish'
AND tt.taxonomy = 'category'
ORDER BY p.post_date ASC LIMIT 1
}}}

Quick and dirty test code:

{{{
add_action( 'init', function() {
        register_post_type( 'book', array( 'label' => 'Books', 'public' => true ) );
});

add_action( 'template_redirect', function() {
        if ( is_singular( 'book' ) )
                var_dump( get_adjacent_post( true, '', false ) );
} );
}}}"	defect (bug)	closed	normal		Post Types		normal	duplicate		batmoo
