首页 > 网站 > 去掉wordpress 3默认文章分类中的category

去掉wordpress 3默认文章分类中的category

2010 年 2 月 4 日 发表评论 阅读评论

最近刚好有位朋友用WordPress建站,想去掉分类URL永久链接中的category

查找了下资料,找到了个算比较简单的方法,记录下
3.2以前版本

打开wp-includes文件夹中的category-template.php

查找以下代码

$catlink = $wp_rewrite->get_category_permastruct();

其后面加上:

$catlink = str_replace('/category', "", $catlink); //add 2010-2-4 del category

3.2以后版本

在目录 wp-includes/category-template.php 文件中搜索:

function get_category_link( $category )

在最后的

return $category;

之前加入

$category = str_replace('/category', "", $category);

保存即可。

分类: 网站 标签:
  1. 2010 年 5 月 6 日 下午 8:57 | #1

    你好,按照你的方法做了,但为什么出现了这个错误:
    Warning: Division by zero in /home/oblue/domains/oblue.net/public_html/wp-includes/category-template.php on line 38
    请帮忙解决下,谢谢。
    我不想使用插件

  2. 2010 年 5 月 7 日 下午 7:18 | #2

    @oblue
    在这个文件中的37行下添加

    $catlink = str_replace('/category', "", $catlink);

    //add 2010-2-4 del category,试试,是不是中英文的字符没写好。

  3. 2010 年 6 月 15 日 下午 10:51 | #3

    链接是改变了,但点进去就是404页面。

  1. 本文目前尚无任何 trackbacks 和 pingbacks.