
Bài toán như sau:
Ví dụ có link gốc:
Chuyên mục cha: your-domain.com/category/tin-tuc/tin-noi-bo/
Chuyên mục con: your-domain.com/category/tin-tuc/tin-noi-bo/
Chuyển thành:
Chuyên mục cha: your-domain.com/category/tin-tuc/tin-noi-bo/
Chuyên mục con: your-domain.com/category/tin-noi-bo/
Bạn chỉ cần thêm đoạn code sau vào functions.php của theme đang kích hoạt rồi vào Cài đặt > đường dẫn tĩnh > ấn Save change là xong nhé
<?php
/*
Author: levantoan.com
Insert this code to functions.php, then update permalink Setting -> Permalink
*/
add_filter('register_taxonomy_args','devvn_remove_parent_slug_category', 10, 2);
function devvn_remove_parent_slug_category($args, $name){
if($name == 'category'){
$args['rewrite']['hierarchical'] = false;
}
return $args;
}
Từ khoá: remove slug parent category in wordpress
- Bình luận