1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| function custom_breadcrumbs() { echo '<a href="' . home_url() . '">首页</a>';
if (is_category()) { $current_cat = get_queried_object(); $ancestors = get_ancestors($current_cat->term_id, 'category'); if ($ancestors) { $ancestors = array_reverse($ancestors); foreach ($ancestors as $ancestor) { $cat = get_category($ancestor); echo ' » <a href="' . get_category_link($ancestor) . '">' . $cat->name . '</a>'; } } echo ' » <span class="current-category">' . $current_cat->name . '</span>'; } }
|