因为我可以使用 wp_insert_post () 使用帖子格式插入我的 php 帖子(例如:post -format- quote )。
\n\n$my_post = array(\n \'post_type\' => \'post\', // "post" para una entrada, "page" para p\xc3\xa1ginas, "libro" para el custom post type libro...\n \'post_status\' => \'publish\', // "draft" para borrador, "future" para programarlo...\n \'post_title\' => $_POST[\'BlogEntranceTitle\'], \n \'post_content\' => $_POST[\'BlogEntranceCode\'], \n \'post_author\' => $user_ID, // \n \'post_category\' => $_POST[\'BlogEntranceCats\'], \n \'tags_input\' => $_POST[\'BlogEntranceTags\'],\n \'post_excerpt\' => $_POST[\'BlogEntranceExcerpt\']\n);\nwp_insert_post( $my_post );\n
Run Code Online (Sandbox Code Playgroud)\n\n成就插入这些选项,但我没有收到添加格式帖子
\n小智 5
为了完整性:不需要“解耦”或将其作为单独的操作,因为它可以与其余设置一起设置在同一数组中。有一个选项(即“tax_input”)可以直接在包含 post 参数的数组中设置分类法。
这就是我用来达到相同效果的方法:
$my_post = array(
'post_type' => 'post' ,
'post_status' => 'publish' ,
'post_title' => $_POST['BlogEntranceTitle'] ,
'post_content' => $_POST['BlogEntranceCode'] ,
'post_author' => $user_ID ,
'post_category' => $_POST['BlogEntranceCats'] ,
'tags_input' => $_POST['BlogEntranceTags'] ,
'post_excerpt' => $_POST['BlogEntranceExcerpt'] ,
'tax_input' => array('post_format' => 'post-format-quote') // <- add this to set post_format
);
wp_insert_post( $my_post );
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3808 次 |
最近记录: |