最新消息:

WordPress默认主题的修改

wordpress admin 2847浏览 0评论

装上WordPress后就开始寻找主题,以前用Z-BLOG的时候就羡慕WordPress的主题,可现在用上了WordPress后却发现WordPress的主题没想象的好.找来找去也没发现中意的.最后还是觉得默认主题看着舒服.

但是默认主题主要有两个缺点.

1.主页上没有自动显示摘要,导致了页面太长.

2.分页不实用(这貌似是通病).

3.没有留言(这貌似也是通病).

先解决分页问题,下载wp-pageavi插件,安装.然后打开主题的index.php文件.

把代码:

1
2
3
4
<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">"navigation"</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">"alignleft"</span><span style="color: #339933;">&gt;&lt;!--</span>p next_posts_link<span style="color: #009900;">(</span>__<span style="color: #009900;">(</span><span style="color: #0000ff;">'&amp;laquo; Older Entries'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'kubrick'</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;--&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">"alignright"</span><span style="color: #339933;">&gt;&lt;!--</span>p previous_posts_link<span style="color: #009900;">(</span>__<span style="color: #009900;">(</span><span style="color: #0000ff;">'Newer Entries &amp;raquo;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'kubrick'</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;--&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>

修改为:

1
<span style="color: #339933;">&lt;</span>div<span style="color: #339933;">&gt;&lt;!--</span>p <span style="color: #b1b100;">if</span><span style="color: #009900;">(</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">(</span><span style="color: #0000ff;">'qiang_pagenavi'</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> qiang_pagenavi<span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #009900;">}</span><span style="color: #339933;">--&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span>

这样分页就解决了,如果想要居中显示,在div里加上“align=”center””属性.

首页摘要显示的修改:

打开index.php。

找到代码:

1

注意the_content()函数中可能会有参数,不过可以无视它。
修改为:

1

最后再加上“read more”的按钮:

1
2
3
<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">"details"</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">"inside"</span><span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">"&amp;lt;?php the_permalink() ?&amp;gt;"</span><span style="color: #339933;">&gt;</span>Read More »<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>

这样,不能显示摘要的问题也解决了。

最后解决留言板的问题。
先复制一份single.php,改名为guestbook.php
在guestbook.php的顶部加上下面的代码:

1

最后,新建一个页面,在页面编辑器的底部,找到页面模板这个选项,从中选择刚才建立的Guestbook,保存就可以了.
但是问题还没完。还要美化一下。
在guestbook.php中把下面的代码删掉:

1
2
3
4
5
6
7
8
9
10
11
12
13
<span style="color: #339933;">&lt;</span>div<span style="color: #339933;">&gt;</span> id<span style="color: #339933;">=</span><span style="color: #0000ff;">"post-"</span><span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">"entry"</span><span style="color: #339933;">&gt;</span>
	<span style="color: #0000ff;">' . __('</span>Read the rest of this entry »<span style="color: #0000ff;">', '</span>kubrick<span style="color: #0000ff;">') . '</span>

<span style="color: #0000ff;">'); ?&amp;gt;
              '</span>

<span style="color: #339933;">&lt;</span>strong<span style="color: #339933;">&gt;</span><span style="color: #0000ff;">' . __('</span>Pages<span style="color: #339933;">:</span><span style="color: #0000ff;">', '</span>kubrick<span style="color: #0000ff;">') . '</span><span style="color: #339933;">&lt;/</span>strong<span style="color: #339933;">&gt;</span> <span style="color: #0000ff;">', '</span>after<span style="color: #0000ff;">' =&amp;gt; '</span>

<span style="color: #0000ff;">', '</span>next_or_number<span style="color: #0000ff;">' =&amp;gt; '</span>number<span style="color: #0000ff;">')); ?&amp;gt;

             trackback from your own site.'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'kubrick'</span><span style="color: #009900;">)</span><span style="color: #339933;">,</span> trackback_url<span style="color: #009900;">(</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> ?<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;&lt;/</span>div<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>

为留言,也就是评论分页:下载wp-commentnavi插件,用法和wp-pagenavi差不多,这就不多说了。
用同样的方法可以修改search.php,archivers.php等等。

转载请注明:爱开源 » WordPress默认主题的修改

您必须 登录 才能发表评论!