Wordpress 修改手记
虽然对写程序一窍不通,偶尔也依照别人的文章,对Wordpress的进行一些微小改动,包括更改主题、插件以及Wordpress程序本身。
为了使以后更换主题,或者升级插件、升级Wordpress程序后,仍然记得需要修改哪些地方,将所有改动记录下来,并随时更新。
1. 增加留言本页面模板文件和留言显示文件。
a. 进入目录/wp-content/themes/purecss(模板名)/;
b. 复制single.php并重命名为guestbook.php;
c. 打开guestbook.php,找到如下语句:
<!--p get_header();-->
在此语句之前加上如下模板标识语句:
<!--p /* Template Name: 留言簿 */ -->
d. 找到如下语句:
<!--p comments_template();-->
改成:
<!--p comments_template('/gbcomments.php');-->
e. 找到如下一段:
<div id="post-<?php the_ID(); ?>" class="post"> <h2 class="pagetitle"><!--p the_title();--></h2> <small class="subtitle"><!--p the_time('m.d.Y')--> by <!--p the_author()--><!--p edit_post_link('Edit', ' - ', '');--> - <a href="#respond"><!--p comments_number('0 Comment', '1 Comment', '% Comments');--></a> Posted in <!--p the_category(', ') ?></small> <div class="entry"></div>
在下面的语句之前加上换行符号:
<div class="entry"></div>
那么这一段语句最终变成了:
<div id="post-<?php the_ID(); ?>" class="post"> <h2 class="pagetitle"><!--p the_title();--></h2> <small class="subtitle"><!--p edit_post_link('Edit', ' - ', '');--> - <a href="#respond"><!--p comments_number('暂时还没有留言', '共有 1 条留言', '共有 % 条留言');--></a></small> <div class="entry"> <!--p the_content();--></div> <!--p the_tags('Tag after ', ', ', '');--></div>
f. 完成以上修改后,存盘并关闭guestbook.php;
g. 复制comments.php并重命名为gbcomments.php;
h. 打开gbcomments.php,找到下面两段语句:
<!-- You can start editing here. -->
<form id="commentform" action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" enctype="application/x-www-form-urlencoded" method="post"> </form>
将这两段之间的语句(不包括这两段),全部剪切/黏贴到下面的语句之后,以产生留言框在留言之前的效果:
i. 找到:
<label for="comment"><strong>Please Comments: </strong></label>
将其中的"Please Comments:" 改成"请留言: ";
j. 找到如下语句:
<h3 id="respond"><span class="hidden"><!--p comments_number('No Responses', 'One Response', '% Responses' )--> to “<!--p the_title();-->”</span></h3>
将其中的"'No Responses', 'One Response', '% Responses' "改成"'没有留言', '1 条留言', '% 条留言' ";
同时,删除下面这一对标签(仅仅是删标签,标签之间的内容不删除):
<span class="hidden">......</span>
k. 修改完毕,存盘并关闭gbcomments.php;
留言倒序也可以通过修改gbcomments.php来实现。不过这里是通过插件 插件 WP Paged Comments 来实现的。
参考文章:
简单5步,制作wordpress留言板
不用插件自制wordpress留言簿
两步创建留言本
2. 简单修改链接页面文件(links.php)。
待续......
说的不错
回复此留言