admin管理员组文章数量:1122846
in functions.php, I wrote this code:
function remove_category($link) {
if (!is_admin() && (is_category() || is_tag())) {
$category = get_queried_object();
$category_id = $category->term_id;
$category_link = get_category_link($category_id);
$url = $category_link;
$arr = parse_url($url);
$path = $arr['path'];
$str_to_arr = explode('/', $path);
$archive = $str_to_arr[2];
$new_url = str_replace('/' . $archive, '', $url);
return $new_url;
}
return $link;
}
add_filter('term_link', 'remove_category',10,1);
The code actually filters out category or tags based on the custom theme I am working on.
Now I have tried applying 'term_link' filter hook, but the site breaks. How can I able to achieve this?
本文标签:
版权声明:本文标题:functions - How can I able to exclude 'Category' and 'Tag' slug from the URL in Wordpress withou 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736299480a1930467.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论