要首先创建菜单,请随意使用快捷代码[AVIA_tree_menu root="your_root_document_title"]
通过将此添加到functions.php
:
function sc_AVIA_tree_menu($atts) {
extract(shortcode_atts(array(\'root\' => \'Start\',), $atts)); //default if empty.
$page = get_page_by_title($root);
$args = array(
\'child_of\' => $page->ID,
\'date_format\' => get_option(\'date_format\'),
\'depth\' => 0,
\'echo\' => 0,
\'post_type\' => \'page\',
\'post_status\' => \'publish\',
\'sort_column\' => \'menu_order, post_title\',
\'title_li\' => __($root)
);
echo \'<ul>\' . wp_list_pages($args) . \'</ul>\';
}
add_shortcode(\'AVIA_tree_menu\', \'sc_AVIA_tree_menu\');
设置没有子级的链接样式,使其看起来不可单击:
.pagenav ul li > a {
text-decoration:underline;
cursor:pointer;
}
.pagenav ul li.page_item_has_children > a {
text-decoration:none;
cursor: default;
}
此后,通过添加此项来防止单击,例如
document.ready
在里面
your_theme/js/functions.js
:
$(\'.pagenav li.page_item_has_children > a\').click(function () {return false;});
我会接受另一个同样好或更好的答案。周末快乐!