直接扔代码
[v_organge]覆盖掉原来的投稿页面/pages/tougao.php
就可以了[/v_organge]
你需要修改两处,一个是投稿页面链接,另一个是邮箱
<?php /** * Template Name: 用户投稿 */ if( isset($_POST['tougao_form']) && $_POST['tougao_form'] == 'send') { global $wpdb; $current_url = 'https://gitcafe.net/tougao'; // 注意修改此处的链接地址 $last_post = $wpdb->get_var("SELECT `post_date` FROM `$wpdb->posts` ORDER BY `post_date` DESC LIMIT 1"); if ( (current_time('timestamp') - strtotime($last_post)) < 20 ) { wp_die('您投稿也太勤快了吧,先歇会儿!点此返回'); } // 表单变量初始化 $name = isset( $_POST['tougao_authorname'] ) ? trim(htmlspecialchars($_POST['tougao_authorname'], ENT_QUOTES)) : ''; $email = isset( $_POST['tougao_authoremail'] ) ? trim(htmlspecialchars($_POST['tougao_authoremail'], ENT_QUOTES)) : ''; $blog = isset( $_POST['tougao_authorblog'] ) ? trim(htmlspecialchars($_POST['tougao_authorblog'], ENT_QUOTES)) : ''; $title = isset( $_POST['tougao_title'] ) ? trim(htmlspecialchars($_POST['tougao_title'], ENT_QUOTES)) : ''; $category = isset( $_POST['cat'] ) ? (int)$_POST['cat'] : 0; $content = isset( $_POST['tougao_content'] ) ? trim(htmlspecialchars($_POST['tougao_content'], ENT_QUOTES)) : ''; // 表单项数据验证 if ( empty($name) || mb_strlen($name) > 20 ) { wp_die('昵称必须填写,且长度不得超过20字。点此返回'); } if ( empty($email) || strlen($email) > 60 || !preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $email)) { wp_die('Email必须填写,且长度不得超过60字,必须符合Email格式。点此返回'); } if ( empty($title) || mb_strlen($title) > 100 ) { wp_die('标题必须填写,且长度不得超过100字。点此返回'); } if ( empty($content) || mb_strlen($content) > 3000 || mb_strlen($content) < 100) { wp_die('内容必须填写,且长度不得超过3000字,不得少于100字。点此返回'); } $post_content = '昵称: '.$name.'<br />Email: '.$email.'<br />blog: '.$blog.'<br />内容:<br />'.$content; $tougao = array( 'post_title' => $title, 'post_content' => $post_content, 'post_category' => array($category) ); // 将文章插入数据库 $status = wp_REPLACE_post( $tougao ); if ($status != 0) { // 投稿成功给博主发送邮件 // somebody#example.com替换博主邮箱 // My subject替换为邮件标题,content替换为邮件内容 wp_mail("sp91@qq.com","乐趣公园新投稿","文章内容"); wp_die('投稿成功!感谢投稿!点此返回', '投稿成功'); } else { wp_die('投稿失败!点此返回'); } } get_header(); ?> <style type="text/css"> .article-content{text-indent:0px;}.article-content h2 {border-left: 8px solid #00A67C;}.article-content blockquote:before {display:none !important;}.article-content h3 {border-left: 4px solid #0095ff;background-color:#fbfbfb}select,textarea,input{width : 999px;}.buttn{-moz-box-shadow:inset 0px 1px 0px 0px #cf866c;-webkit-box-shadow:inset 0px 1px 0px 0px #cf866c;box-shadow:inset 0px 1px 0px 0px #cf866c;background:-webkit-gradient(linear,left top,left bottom,color-stop(0.05,#d0451b),color-stop(1,#bc3315));background:-moz-linear-gradient(top,#d0451b 5%,#bc3315 100%);background:-webkit-linear-gradient(top,#d0451b 5%,#bc3315 100%);background:-o-linear-gradient(top,#d0451b 5%,#bc3315 100%);background:-ms-linear-gradient(top,#d0451b 5%,#bc3315 100%);background:linear-gradient(to bottom,#d0451b 5%,#bc3315 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#d0451b',endColorstr='#bc3315',GradientType=0);background-color:#d0451b;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;border:1px solid #942911;display:inline-block;cursor:pointer;color:#ffffff;font-family:arial;font-size:13px;padding:6px 24px;text-decoration:none;text-shadow:0px 1px 0px #854629;height : 40px;} </style> <div class="pagewrapper clearfix"> <aside class="pagesidebar"> <ul class="pagesider-menu"> <?php echo str_replace("</ul></div>", "", ereg_replace("<div[^>]*><ul[^>]*>", "", wp_nav_menu(array('theme_location' => 'pagemenu', 'echo' => false)) )); ?> </ul> </aside> <div class="pagecontent"> <header class="pageheader clearfix"> <h1 class="pull-left"> <a href="<?php the_permalink() ?>"><?php the_title(); ?></a> </h1> <div class="pull-right"><!-- 百度分享 --> <?php deel_share() ?> </div> </header> <?php while (have_posts()) : the_post(); ?> <div class="article-content"> <?php the_content(); ?> <!-- 关于表单样式,请自行调整--> <form class="ludou-tougao" method="post" action="<?php echo $_SERVER["REQUEST_URI"]; $current_user = wp_get_current_user(); ?>"> <div style="text-align: left; padding-top: 10px;"> <label for="tougao_authorname">昵称:*[不要中文哦]</label> <input type="text" size="80" value="<?php if ( 0 != $current_user->ID ) echo $current_user->user_login; ?>" id="tougao_authorname" name="tougao_authorname" /> </div> <div style="text-align: left; padding-top: 10px;"> <label for="tougao_authoremail">E-Mail:*</label> <input type="text" size="80" value="<?php if ( 0 != $current_user->ID ) echo $current_user->user_email; ?>" id="tougao_authoremail" name="tougao_authoremail" /> </div> <div style="text-align: left; padding-top: 10px;"> <label for="tougao_authorblog">您的博客:[自带http://哦]</label> <input type="text" size="80" value="<?php if ( 0 != $current_user->ID ) echo $current_user->user_url; ?>" id="tougao_authorblog" name="tougao_authorblog" /> </div> <div style="text-align: left; padding-top: 10px;"> <label for="tougao_title">文章标题:*</label> <input type="text" size="80" value="" id="tougao_title" name="tougao_title" /> </div> <div style="text-align: left; padding-top: 10px;"> <label for="tougaocategorg">分类:*</label> <?php wp_dropdown_categories('hide_empty=0&id=tougaocategorg&show_count=1&hierarchical=1'); ?> </div> <div style="text-align: left; padding-top: 10px;"> <label style="vertical-align:top" for="tougao_content">文章内容:*</label> <textarea rows="15" cols="auto" placeholder="亲,不来一发咩……." id="tougao_content" name="tougao_content"></textarea> </div> <div style="text-align: center; padding-top: 10px;"> <input type="hidden" value="send" name="tougao_form" /> <input class="buttn" type="submit" value="提交" /> <input class="buttn" type="reset" value="重填" /> </div> </form> <br/> <?php comments_template('', true); endwhile; ?> </div> </div> <?php get_footer(); ?>
-- 完 --
提交后,页面变成空白,求云落大哥修复一下吧!地址在我网址里面!
看了又看,还是没搞懂怎么添加投稿页面
@淘宝折扣网 本来就有的功能,新建页面,选择模板