1
在我生成的php導航菜單中,我想使父項不可點擊,並且與頁面無關。我只是希望他們在徘徊時透露孩子。使導航菜單中的父項非超鏈接
PHP代碼生成的導航菜單:
<?php wp_list_pages('sort_column=menu_order&title_li='); ?>
非常感謝!
在我生成的php導航菜單中,我想使父項不可點擊,並且與頁面無關。我只是希望他們在徘徊時透露孩子。使導航菜單中的父項非超鏈接
PHP代碼生成的導航菜單:
<?php wp_list_pages('sort_column=menu_order&title_li='); ?>
非常感謝!
選中此項。用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;
}
?>
感謝您的幫助!如果我得到這個正確的,這些網頁將不會顯示?不過,我確實希望他們只顯示不是超鏈接。 – Twister013
你用它作爲菜單嗎?如果是的話,爲什麼不在WordPress中創建一個「自定義鏈接」,然後編輯鏈接並刪除URL,或者我編輯了上面的答案。 –
其實我從零開始創建了一個主題,我無法訪問可以創建自定義鏈接的wp頁面。剛剛嘗試過你編輯的答案,看起來完全像我想要的。不幸的是,我的網頁無法再加載。我把它放在我的PHP代碼上面,是否應該放在其他地方?非常感謝,看到了隧道的盡頭,終於! – Twister013