在之前的建站教程中,我们介绍了WordPress网站添加在线投稿发布功能,可以实现用户在网站前台投稿和发布的功能。
这个投稿功能可以写标题和投稿内容等,为了满足网站制作过程中某些功能的需求,让Wordpress投稿页面添加更多的参数,今天学做网站论坛介绍一下Wordpress投稿页面如何添加插入自定义栏目参数。
更换的代码如下:
$tougao = array( 'post_title' => $title, //标题 'post_content' => $post_content, //内容 'post_status' => 'pending', //待审 'tags_input' => $tags, //标签 'post_category' => array($category) //分类 ); //将文章插入数据库 $status = wp_insert_post( $tougao ); if ($status != 0){ //将自定义域写入最新待审文章 global $wpdb; $myposts = $wpdb->get_results(" SELECT ID FROM $wpdb->posts WHERE post_status = 'pending' AND post_type = 'post' ORDER BY post_date DESC "); add_post_meta($myposts[0]->ID, 'tiwenzhe', $name); //插入投稿人昵称的自定义域