• 12
  • 九月

[分享]我实践的一些WordPress高级应用

Kenami 发布于 15:12:19  |  阅读 777 次 |  评论  

WordPress是开源的PHP博客模板,其可以免费使用的插件成千上万,如果你想要的功能,没能找到合适的插件,其实简单的修改代码也能给你很多惊喜。

1、.htaccess文件修改,让博客更多彩:
合理的运用.htaccess的URL重写功能可以实现WORDPRESS不同分类页面的不同显示,例如本博客首页第一条显示全文,其他文章显示描述内容,全部文章显示文章标题和标签、分类,等…
这是如何实现的呢?我们先看.htaccess文件

RewriteEngine On
#404
ErrorDocument 404 /error_404.html
AddDefaultCharset UTF-8
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule . /index.php [L]
#/2008-09-03/92.html
RewriteRule ^([a-z0-9\-]+)/([a-z0-9\-]+)\.html$ /index.php?action=post [L,NS,QSA]
#category/all
RewriteRule ^category/all$ /index.php?action=all [L,NS,QSA]
RewriteRule ^category/all/page/([a-z0-9\-]+)$ /index.php?action=all [L,NS,QSA]
#map
RewriteRule ^map\.html$ /index.php [L]
#/category/uncategorized
RewriteRule ^category/([\w\-\.]+)$ /index.php [L]
#/category/uncategorized/think
RewriteRule ^category/([\w\-\.]+)/([\w\-\.]+)$ /index.php [L]
#/2008/09
RewriteRule ^([a-z0-9\-]+)/([a-z0-9\-]+)/?$ /index.php [L]
RewriteRule ^([a-z0-9\-]+)/([a-z0-9\-]+)/page/([a-z0-9\-]+)$ /index.php [L]
#/2008/09/03
RewriteRule ^([a-z0-9\-]+)/([a-z0-9\-]+)/([a-z0-9\-]+)$ /index.php [L]
#tag/
RewriteRule ^tag/(.*)$ /index.php [L]
#feed
RewriteRule ^feed$ /index.php [L]
#comments/feed
RewriteRule ^comments/feed$ /index.php [L]
#about
RewriteRule ^about$ /index.php [L]


查看全文>>