给自己的WordPress博客增加留言板

显然,对于wordpress,我是一个菜鸟,为了一个留言板的制作和修改,用了一上午的时间,现在将学习手记记载如下。

第一步,当然是在互联网上找方法,这里我选择的是[宋夏的博客]上传授的方法

拷贝single.phpcomments.php两个文件为 guestbook.php 和 guestcomments.php(COPY都是很容易的啦 [强] )

下面是重要的一步,修改guestbook.php中代码,即在最顶部增加如下代码

 <?php
 /*
 Template Name: Guestbook
 */
 ?>

另一外需要修改的代码是,查找

<?php comments_template()

在括号里加入

‘/guestcomments.php’

将新生成的2个文件上传到相关主题的目录中,形如\WordPress\wp-content\themes\主题名\

第二步,用后台新建页面的方式,需注意选择模板为guestbook.php

新生成的页面,需打开快速编辑,添选“允许评论”,这样生成的网页上就会有评论界面出现,可以将评论界面作为留言的主战场。

第三步工作就是优化

主要优化的也是上述两个文件,其中guestbook.php中修改的较多,如删除文章日期(即生成留言板页面的日期)、排板中不需要在留言板中出现的内容(如主题自带的推荐、上一篇、下一篇等标签)。

最重要的是在两个文件中搜索下“评论”两字,修改为“留言”,这样对得起留言板的风格吧。

至于留言的先后顺序选择(如让最新发布的留言位于最上边),网上的方法是修改guestcomments.php中的foreach循环代码(加入array_reverse),实际上在最新的wordpress中,后台有[设置]-[讨论]中进行先后顺序的设定。可以简化操作,不一定要加入代码。

菜鸟的方法,拿来主义,即用代码,进一步优化得使用一些php和css了。

One thought on “给自己的WordPress博客增加留言板

  1. Spring cleaning the premises is a good case to do a huge mass of work on tidying up urban areas, private households and offices, apartments.
    Roads, courtyards, parks, squares and other urban areas not only clear from the pollution Today, cleaning in the spring time is a good case do cleaning the house, cottage and also in my apartment.
    Streets, courtyards, gardens, squares and urban territories very important not only clear from the dirt that formed during the winter, take out the garbage, but also prepare for the summer period. For this it is necessary to restore damaged bardyurfs and pavements repair broken architectural small forms sculptures, flowerpots,artificial reservoirs,benches, fences, and so on, refresh fences, painting and other.
    We hold spring cleaning not only in urban areas , but with joy we will certainly help clean .
    Our specialists organizations Woodlawn spend spring cleaning.

    Our Partnership international company carries out spring garden cleaning not only in urban areas , but with joy we will certainly help tidy up .
    Our trained specialists Midwood ready to hold spring cleaning cottages.
    Our Limited liability Partnership cleaning company Inwood CLAUDIA, is engaged spring general cleaning in Concord under the direction of MCKEE.

    Home cleaning services prices Union Square – spring cleaning manhattan

发表评论

电子邮件地址不会被公开。 必填项已用*标注