2017-08-04 145 views
0

我正在使用以下代码将父级子页面的菜单打印到ul li菜单中。它的效果很好。然而,我没有能力只在当前页面的用户名 - 类似wordpress用于主菜单代码的类名称管道 - 我很好奇我需要在此代码中更改管道当前菜单项班级名称?将类名称添加到当前菜单项目为父项目的子页面在WordPress中的菜单

function nee_list_child_pages() { 

    global $post; 

    $string = ''; 

    if (is_page() && $post->post_parent) 

     $childpages = wp_list_pages('sort_column=menu_order&title_li=&child_of=' . $post->post_parent . '&echo=0'); 
    else 
     $childpages = wp_list_pages('sort_column=menu_order&title_li=&child_of=' . $post->ID . '&echo=0'); 

    if ($childpages) { 
     $string = '<div id="sidebar_menu"><ul>' . $childpages . '</ul></div>'; 

     return $string; 
    } 
} 

add_shortcode('wpb_childpages', 'nee_list_child_pages'); 

回答

相关问题