你不必考虑,WordPress会处理好的。
让我们看看wp_insert_post
source code...
在线3203 您将发现:
if ( empty($post_name) ) {
if ( !in_array( $post_status, array( \'draft\', \'pending\', \'auto-draft\' ) ) ) {
$post_name = sanitize_title($post_title);
} else {
$post_name = \'\';
}
} else {
// On updates, we need to check to see if it\'s using the old, fixed sanitization context.
$check_name = sanitize_title( $post_name, \'\', \'old-save\' );
if ( $update && strtolower( urlencode( $post_name ) ) == $check_name && get_post_field( \'post_name\', $post_ID ) == $check_name ) {
$post_name = $check_name;
} else { // new post, or slug has changed.
$post_name = sanitize_title($post_name);
}
}
所以如果没有
post_name
则WP将根据
post_title
.
然后在线3325:
$post_name = wp_unique_post_slug( $post_name, $post_ID, $post_status, $post_type, $post_parent );
因此,WP将考虑
post_name
.