Title: 中文  分类名 导致 get_category_link 返回空白
Last modified: 2012 年 3 月 2 日

---

# 中文 分类名 导致 get_category_link 返回空白

 *  [emondora](https://cn.wordpress.org/support/users/emondora/)
 * (@emondora)
 * [14年、 8月前](https://cn.wordpress.org/support/topic/%e4%b8%ad%e6%96%87-%e5%88%86%e7%b1%bb%e5%90%8d-%e5%af%bc%e8%87%b4-get_category_link-%e8%bf%94%e5%9b%9e%e7%a9%ba%e7%99%bd/)
 * 建立出来的分类，如果CATEGORY的名称或者别名中含有中文，则会导致以下函数get_category_link
   返回”,也就是is_wp_error($category)会为true..如何解决这个问题？
    不知道是不是我
   个人的问题，还是有别人也遇到同样的问题，谢谢！！ 代码如下： function get_category_url(
   $current_category){ // Get the ID of a given category $category_id=get_cat_ID(
   $current_category);
 *  // Get the URL of this category
    $category_link=get_category_link($category_id);//
   如果此id对应的分类为中文名，则会返回错误的结果
 *  return $category_link;
    }//此处为自定义的函数 function get_category_link( $category){
   if ( ! is_object( $category ) ) $category = (int) $category;
 *  $category = get_term_link( $category, ‘category’ );
 *  if ( is_wp_error( $category ) )
    return ”;//分类名为中文则会执行这一语句！
 *  return $category;
    }

 话题 ‘中文 分类名 导致 get_category_link 返回空白’不再接受新回复。

## 标签

 * [get category link 中文化 分类名](https://cn.wordpress.org/support/topic-tag/get-category-link-%e4%b8%ad%e6%96%87%e5%8c%96-%e5%88%86%e7%b1%bb%e5%90%8d/)

 * 发表在: [DIY 问题](https://cn.wordpress.org/support/forum/tech-discussions/)
 * 0个回复
 * 1人参与
 * 最后的回复:[emondora](https://cn.wordpress.org/support/users/emondora/)
 * 最后动态：[14年、 8月前](https://cn.wordpress.org/support/topic/%e4%b8%ad%e6%96%87-%e5%88%86%e7%b1%bb%e5%90%8d-%e5%af%bc%e8%87%b4-get_category_link-%e8%bf%94%e5%9b%9e%e7%a9%ba%e7%99%bd/)
 * 状态： 尚未解决

## 话题

### 最热话题

### 没有回复的话题

### 非支持话题

### 已解决的话题

### 未解决的话题

### 所有话题
