在我生成的php导航菜单中,我想让父项无法点击并且与页面无关。我只是希望他们在盘旋时透露孩子。
生成导航菜单的PHP代码:
<?php wp_list_pages('sort_column=menu_order&title_li='); ?>
非常感谢!
答案 0 :(得分:0)
检查一下。使用depth
。
<?php
global $post;
wp_list_pages( array(
// Only pages that are children of the current page
'child_of' => $post->ID,
// Only show one level of hierarchy
'depth' => 1
) );
?>
这样:
<?php
function removeParentCatLinks() {
$cats = wp_list_categories('echo=0&title_li');
$cats = explode("</li>", $cats);
$count = 0;
foreach($cats as $cat) {
if(strstr($cat,"<ul class='children'>")) {
$cat = explode("<ul class='children'>", $cat);
$cat[0] = str_replace('</a>','',$cat[0]);
$cat[0] = preg_replace('/\<a(.*)\>/','',$cat[0]);
$cat = implode("<ul class='children'>", $cat);
}
$cats[$count] = $cat;
$count++;
}
$cats = implode('</li>',$cats);
echo $cats;
}
?>