mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Return nothing in get_adjacent_post() when $in_same_cat = true but the post doesn't support (or otherwise have) categories. Avoids SQL error. props batmoo, SergeyBiryukov. fixes #15959.
git-svn-id: http://core.svn.wordpress.org/trunk@22472 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e5c1d8d7af
commit
5b8081b787
@ -1133,7 +1133,11 @@ function get_adjacent_post( $in_same_cat = false, $excluded_categories = '', $pr
|
||||
$join = " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id";
|
||||
|
||||
if ( $in_same_cat ) {
|
||||
if ( ! is_object_in_taxonomy( $post->post_type, 'category' ) )
|
||||
return '';
|
||||
$cat_array = wp_get_object_terms($post->ID, 'category', array('fields' => 'ids'));
|
||||
if ( ! $cat_array || is_wp_error( $cat_array ) )
|
||||
return '';
|
||||
$join .= " AND tt.taxonomy = 'category' AND tt.term_id IN (" . implode(',', $cat_array) . ")";
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user