1、在当前使用的主题根目录下建一个模板:
<?php
/**
* Template Name: Front Post(前台发布文章)
* 作者:碎石头
* 博客:http://sheng.iteye.com
*
*/
if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'post' ) {
if (!is_user_logged_in() ) auth_redirect();
if(!current_user_can( 'publish_posts' ) ) {
wp_redirect( get_bloginfo( 'url' ) . '/' );
exit;
}
check_admin_referer( 'new-post' );
$user_id = $current_user->user_id;
if (isset ($_POST['title'])) {
$title = $_POST['title'];
} else {
echo '请输入文章标题!';
}
if (isset ($_POST['content'])) {
$content = $_POST['content'];
} else {
echo '请输入文章内容!';
}
$tags = $_POST['post_tags'];
$post = array(
'post_author' =