Php 阵列拼接不保留“;小径“U端”;
我是一个新手,有一段Wordpress代码,其中有一个小故障 抱歉,如果我的问题很愚蠢,尽管我购买主题的地方的支持似乎迟迟无法回答 我会把它贴上去,也许有人能帮上忙。如果没有人能解决这个问题,我将删除这个问题 代码为my上的面包屑导航添加了一些更改 我认为问题在于:Php 阵列拼接不保留“;小径“U端”;,php,Php,我是一个新手,有一段Wordpress代码,其中有一个小故障 抱歉,如果我的问题很愚蠢,尽管我购买主题的地方的支持似乎迟迟无法回答 我会把它贴上去,也许有人能帮上忙。如果没有人能解决这个问题,我将删除这个问题 代码为my上的面包屑导航添加了一些更改 我认为问题在于: // Add the trail back on to the end. $links[] = $trail['trail_end']; // Add the new links, and the original trail's
// 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 );
这两行代码应该在面包屑的末尾添加一个
,旁边是“Xpand Xtreme Pump”(在我的链接示例中)
代码如下:
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()
试试这个:
...
// 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'];
...
。。。
//用你的跨距标签包住轨迹的末端
$trail['trail_end']=''。结束($trail)。”;
//将轨迹添加回末端。
$links[]=$trail['trail_end'];
...
请记住,这是一种黑客行为,我建议您在呈现面包屑的模板中执行此操作。在执行
$links[]=
命令之前,是否可以执行var\u dup($trail)
转储操作?这是var\u dup:array(3){[0]=>string(150)“Home”[1]=>string(72)“Products”[“trail\u end”]=>string(17)“Elite Mass Gainer”}你能在$links[]
之前做一个var\u dump($links)
吗?数组(1){[0]=>string(123)“Gainere”}所以你希望结果菜单看起来像:主页->产品->Gainere->精英大众Gainer?除了最后一个链接,所有的链接都可以点击吗?