2011-03-28 97 views
0

我正在編輯Wordpress中的post-template.php。 function start_el迴響菜單。在這裏,我想檢查頁面是否是頂級頁面,這樣我就可以將一個名爲「top」的新類僅添加到頂層頁面li。 如何檢查頁面/鏈接是否爲最高級別?我只需要這個,因爲我可以做其餘的。WordPress的 - 如何檢查菜單鏈接是否是頂級?

我試着

if ($page->post_parent) { do_something(); } 

,但它不工作...

(我已經在同一個班成功的類的名字current_page_item and current_page_ancestor, current_page_parent因爲我改current使用一個自定義的jquery菜單,使用這個類。)

非常感謝!

回答

0

你好,如果你想添加類與jQuery頂級網頁,然後做一些事情


$('ul#main-menu>li').addClass('top_level'); 

這裏UL#主菜單是你的菜單UL標識

+0

你是一個生命的救星!非常感謝你 - 它的作品非常漂亮! – Cris 2011-03-28 21:48:05

+0

謝謝你的歡迎 – Anjum 2011-03-29 08:20:09

相關問題