Ticket #13096: get_adjacent_post.patch
| File get_adjacent_post.patch, 1.8 KB (added by zerzix, 3 years ago) |
|---|
-
wp-includes/link-template.php
989 989 * @param bool $previous Optional. Whether to retrieve previous post. 990 990 * @return string 991 991 */ 992 function get_adjacent_post($in_same_cat = false, $excluded_categories = '', $previous = true ) {992 function get_adjacent_post($in_same_cat = false, $excluded_categories = '', $previous = true, $taxonomy = 'category') { 993 993 global $post, $wpdb; 994 994 995 995 if ( empty( $post ) ) … … 1003 1003 $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"; 1004 1004 1005 1005 if ( $in_same_cat ) { 1006 $cat_array = wp_get_object_terms($post->ID, 'category', array('fields' => 'ids'));1007 $join .= " AND tt.taxonomy = ' category' AND tt.term_id IN (" . implode(',', $cat_array) . ")";1006 $cat_array = wp_get_object_terms($post->ID, $taxonomy, array('fields' => 'ids')); 1007 $join .= " AND tt.taxonomy = '".$taxonomy."' AND tt.term_id IN (" . implode(',', $cat_array) . ")"; 1008 1008 } 1009 1009 1010 $posts_in_ex_cats_sql = "AND tt.taxonomy = ' category'";1010 $posts_in_ex_cats_sql = "AND tt.taxonomy = '".$taxonomy."'"; 1011 1011 if ( !empty($excluded_categories) ) { 1012 1012 $excluded_categories = array_map('intval', explode(' and ', $excluded_categories)); 1013 1013 if ( !empty($cat_array) ) { … … 1016 1016 } 1017 1017 1018 1018 if ( !empty($excluded_categories) ) { 1019 $posts_in_ex_cats_sql = " AND tt.taxonomy = ' category' AND tt.term_id NOT IN (" . implode($excluded_categories, ',') . ')';1019 $posts_in_ex_cats_sql = " AND tt.taxonomy = '".$taxonomy."' AND tt.term_id NOT IN (" . implode($excluded_categories, ',') . ')'; 1020 1020 } 1021 1021 } 1022 1022 }
