有没有办法将自定义URL添加到wp_insert_post
作用
$my_post = array(
\'post_title\' => wp_strip_all_tags( $_POST[\'post_title\'] ),
\'post_content\' => $_POST[\'post_content\'],
\'post_status\' => \'publish\',
\'post_author\' => 1,
\'post_category\' => array( 8,39 )
);
wp_insert_post( $my_post );
最合适的回答,由SO网友:Sasa1234 整理而成
您可以使用post_name
参数
$my_post = array(
\'post_title\' => wp_strip_all_tags( $_POST[\'post_title\'] ),
\'post_content\' => $_POST[\'post_content\'],
\'post_status\' => \'publish\',
\'post_author\' => 1,
\'post_category\' => array( 8,39 ),
\'post_name\' => \'your-url\'
);
wp_insert_post( $my_post );