如果不需要太美观,只求简单快捷,那么可以直接使用wordpress的新建页面功能,以一个单独页面作为留言板也是比较不错的选择。
wp的页面模板 主要在主题文件夹下的page.php,每个主题都会有这个文件。 我们可以把它拿来当作模板改成另一个留言板模板。
最简单的修改方式就是 新建一个php文本,把page.php 里面的全部源码粘贴过来,
然后在这些源码的最前面加上两句代码
<?php /* Template Name: guestbook */ ?> <?php get_header(); ?> <div class="content-wrap"> <div class="content"> <?php while (have_posts()) : the_post(); ?> <header class="article-header"> <h1 class="article-title"><a rel="nofollow" href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1> <div class="meta"> <span class="muted"><i class="icon-user icon12"></i> <a rel="nofollow" href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ) ?>"><?php echo get_the_author() ?></a></span> <time class="muted"><i class="ico icon-time icon12"></i> <?php the_time('Y-m-d');?></time> <span class="muted"><i class="ico icon-eye-open icon12"></i> <?php deel_views('浏览'); ?></span> <?php if ( comments_open() ) echo '<span class="muted"><i class="icon-comment icon12"></i> <a rel="nofollow" href="'.get_comments_link().'">'.get_comments_number('去', '1', '%').'评论</a></span>'; ?> <?php edit_post_link('[编辑]'); ?> </div> </header> <article class="article-content"> <?php the_content(); ?> </article> <?php comments_template('', true); ?> <?php endwhile; ?> </div> </div> <?php get_sidebar(); get_footer(); ?>
如上代码所示,红色的部分就是新添加的代码,其中 guestbook 就是留言板的“模板名称”。
而其下面的代码全部是从page.php里面复制粘贴过来的而已。
将上面的代码一并保存成一个php文件!比如:guestbook.php ,然后将它上传到你的主题文件夹下。
最后,在后台新建页面,模板选择 guestbook ,发布! 将发布出来的页面添加到导航菜单,大功告成!
本站文章除注明转载/出处外,均为本站原创或翻译。若要转载但请务必注明出处,尊重他人劳动成果。
转载请注明出处链接 : https://www.inlojv.com/481.html