WordPress菜单walker - 在end_lvl函数中获取父项文本

时间:2017-02-24 21:12:05

标签: php wordpress menu submenu wordpress-hook

我有一个父分类名称的父菜单项。我想添加一个超级菜单,其中包含子菜单左侧菜单分类中的精选帖子。

此代码可正常显示html,但我不知道如何获取父菜单项文本(查询精选帖子详细信息)。

public function end_lvl( &$output, $depth = 0, $args = array() ) {
    $indent = str_repeat( "\t", $depth );
    $output .= "$indent</ul></div><div class=\"col-md-8\">Featured Post</div></div>\n";
}

如何在end_lcl函数中获取父菜单项文本?

public function end_lvl( &$output, $depth = 0, $args = array() ) {
    $indent = str_repeat( "\t", $depth );
    // This is the piece I'm missing
    $parent_menu_item_text = ??????;
    $args = array( 'taxonomy' => $parent_menu_item_text );
    // Query the post with the $args etc..
    $output .= "$indent</ul></div><div class=\"col-md-8\">Featured Post</div></div>\n";
}

我见过这个answer,但似乎从那时起(2013年)类代码已经更新

0 个答案:

没有答案