我正在研究使用wpapi通过AJAX插入帖子。
向自定义帖子类型动态添加标签的正确方法是什么?这些标记不是预定义的,而是由用户根据需要创建的。
目前我正在做:
$tags = explode(" ", $_POST[\'post_tags\']);
$new_entry = array(
\'post_title\' => $_POST[\'post_title\'],
\'post_content\' => $_POST[\'post_content\'],
\'post_status\' => \'publish\',
\'post_author\' => $current_user->ID,
\'post_type\' => \'customposttype\',
\'post_tags\' => $tags);
$created = wp_insert_post( $new_entry );
(是的,这是原型代码,我还没有清理输入:))