我是个新手,有一段Wordpress代码,里面有一个小问题。
很抱歉,如果我的问题是愚蠢的,虽然支持我购买的主题似乎是一个很大的延迟回答。
我会粘贴它也许有人能帮上忙。如果没有人能解决这个问题,我将删除这个问题。
该代码为我的上的面包屑导航添加了一些更改。
我认为的问题是:
// Add the trail back on to the end.
$links[] = $trail['trail_end'];
// Add the new links, and the original trail's end, back into the trail.
array_splice( $trail, 1, count( $trail ) - 1, $links );这两行代码应该在单词“Xtreme”(在我的链接示例中)后面的面包屑末尾添加一个<span class="trail-end"></span> (在我的链接示例中)
以下是代码:
function woo_custom_breadcrumbs_trail_add_product_categories ( $trail ) {
if ( ( get_post_type() == 'product' ) && is_singular() ) {
global $post;
$taxonomy = 'product_cat';
$terms = get_the_terms( $post->ID, $taxonomy );
$links = array();
if ( $terms && ! is_wp_error( $terms ) ) {
foreach ( $terms as $c ) {
$parents = woo_get_term_parents( $c->term_id, $taxonomy, true, ', ', $c->name, array() );
if ( $parents != '' && ! is_wp_error( $parents ) ) {
$parents_arr = explode( ', ', $parents );
foreach ( $parents_arr as $p ) {
if ( $p != '' ) { $links[] = $p; }
}
}
}
// Add the trail back on to the end.
$links[] = $trail['trail_end'];
// Add the new links, and the original trail's end, back into the trail.
array_splice( $trail, 1, count( $trail ) - 1, $links );
}
}
return $trail;
} // End woo_custom_breadcrumbs_trail_add_product_categories()发布于 2012-01-31 21:56:37
试试这个:
...
// Wrap the trail_end with your span tag
$trail['trail_end'] = '<span class="trail-end">' . end($trail) . '</span>';
// Add the trail back on to the end.
$links[] = $trail['trail_end'];
...记住,这是一个黑客,我建议在渲染面包屑的模板中这样做。
https://stackoverflow.com/questions/9084315
复制相似问题