在之前的建站教程中,我們介紹了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); //插入投稿人昵稱的自定義域