给wordpress新建一个漂亮的留言板
1、首先我们用dreamweaver新建一个PHP空白页面,在此页面顶部设置你要建的留言板的名称,代码如下,红色部分就是留言板的名称,可以自己随意取,建议用英文吧,不要纯中文。<?php/*Template Name: liuyanban*/?>
2、 打开你主题的目录,找到page.php页面,然后把里面的代码全部翱务校肢复制过来粘贴到我们第一步新建的留言板页面。第一二步完成后代码如下:<?php/*Template Name: liu烤恤鹇灭yanban*/?><?php get_header(); ?><?php if (have_posts()) : the_post(); update_post_caches($posts); ?> <div id=”post-<?php the_ID(); ?>”> <h2><?php the_title(); ?></h2> <div> <?php edit_post_link(__(‘Edit’, ‘inove’), ‘<span>’, ‘</span>’); ?> <?php if ($comments || comments_open()) : ?> <span><a href=”#respond”><?php _e(‘Leave a comment’, ‘inove’); ?></a></span> <span><a href=”#comments”><?php _e(‘Go to comments’, ‘inove’); ?></a></span> <?php endif; ?> <div></div> </div> <div> <?php the_content(); ?> <div></div> </div> </div> <?php include(‘templates/comments.php’); ?><?php else : ?> <div> <?php _e(‘Sorry, no posts matched your criteria.’, ‘inove’); ?> </div><div id=”comments”><?php comments_template(”,true); ?></div><?php endif; ?><?php get_footer(); ?>
3、在上面的代码里面加上评论调用函数<?php comments_template(”,true); ?>
4、最后得到的留言本代码如下,将此页面秽颢擤崮存为“liuyanban.php”:<?php/*Template Nam髫潋啜缅e: liuyanban*/?><?php get_header(); ?><?php if (have_posts()) : the_post(); update_post_caches($posts); ?> <div id=”post-<?php the_ID(); ?>”> <h2><?php the_title(); ?></h2> <div> <?php edit_post_link(__(‘Edit’, ‘inove’), ‘<span>’, ‘</span>’); ?> <?php if ($comments || comments_open()) : ?> <span><a href=”#respond”><?php _e(‘Leave a comment’, ‘inove’); ?></a></span> <span><a href=”#comments”><?php _e(‘Go to comments’, ‘inove’); ?></a></span> <?php endif; ?> <div></div> </div> <div> <?php the_content(); ?> <div></div> </div> </div> <?php include(‘templates/comments.php’); ?><?php else : ?> <div> <?php _e(‘Sorry, no posts matched your criteria.’, ‘inove’); ?> </div><div id=”comments”><?php comments_template(”,true); ?></div><?php endif; ?><?php get_footer(); ?>
5、最后到WordPress后台-页面-新建一个页面,命名“留言板”。给此页面选择模板“liuyanban”,页面内容里面随便输入你想要给留言者看的内容就行了。