Don't set/get tags or categories for post types that do not support them. fixes #13346
git-svn-id: https://develop.svn.wordpress.org/trunk@14561 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
5d13bccc69
commit
d5308265cd
|
@ -1993,11 +1993,18 @@ function wp_get_single_post($postid = 0, $mode = OBJECT) {
|
|||
|
||||
// Set categories and tags
|
||||
if ( $mode == OBJECT ) {
|
||||
$post->post_category = array();
|
||||
if ( is_object_in_taxonomy($post->post_type, 'category') )
|
||||
$post->post_category = wp_get_post_categories($postid);
|
||||
$post->tags_input = array();
|
||||
if ( is_object_in_taxonomy($post->post_type, 'post_tag') )
|
||||
$post->tags_input = wp_get_post_tags($postid, array('fields' => 'names'));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$post['post_category'] = array();
|
||||
if ( is_object_in_taxonomy($post['post_type'], 'category') )
|
||||
$post['post_category'] = wp_get_post_categories($postid);
|
||||
$post['tags_input'] = array();
|
||||
if ( is_object_in_taxonomy($post['post_type'], 'post_tag') )
|
||||
$post['tags_input'] = wp_get_post_tags($postid, array('fields' => 'names'));
|
||||
}
|
||||
|
||||
|
@ -2240,9 +2247,10 @@ function wp_insert_post($postarr = array(), $wp_error = false) {
|
|||
$wpdb->update( $wpdb->posts, array( 'post_name' => $data['post_name'] ), $where );
|
||||
}
|
||||
|
||||
if ( is_object_in_taxonomy($post_type, 'category') )
|
||||
wp_set_post_categories( $post_ID, $post_category );
|
||||
// old-style tags_input
|
||||
if ( isset( $tags_input ) )
|
||||
|
||||
if ( isset( $tags_input ) && is_object_in_taxonomy($post_type, 'post_tag') )
|
||||
wp_set_post_tags( $post_ID, $tags_input );
|
||||
|
||||
// new-style support for all custom taxonomies
|
||||
|
|
Loading…
Reference in New Issue