Make WordPress Core


Ignore:
Timestamp:
08/11/2022 07:58:21 PM (19 months ago)
Author:
johnbillion
Message:

Posts, Post Types: Prevent categories from being overwritten when updating a post using wp_insert_post().

This prevents existing category relationships being overridden with the default category when none is provided in the post data.

Props markoheijnen, leewillis77, desrosj

Fixes #19954

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r53878 r53883  
    41434143        // Filter out empty terms.
    41444144        $post_category = array_filter( $postarr['post_category'] );
     4145    } elseif ( $update && ! isset( $postarr['post_category'] ) ) {
     4146        $post_category = $post_before->post_category;
    41454147    }
    41464148
Note: See TracChangeset for help on using the changeset viewer.