あなたがそれらを理解するまで、Custom Walkersは、で動作するように痛みのビットです。
以下のカスタムウォーカーコードでは、必要なものを得ることができます。あなたのテーマのfunctions.php
ファイルにこれを追加します。
class Custom_Button_Walker extends Walker_Nav_Menu {
// We only care about the "end level" part of the menu, where closing </ul> tags are generated
public function end_lvl(&$output, $depth = 0, $args = array()) {
// This is from WP core code
$indent = str_repeat("\t", $depth);
// This line ensures we only add it on the proper level
$button = (0 == $depth) ? "{$indent}<button type=\"button\">Click Me!</button>\n" : '';
// This line is modified to include the button markup
$output .= "{$indent}</ul>\n{$button}";
}
}
は、カスタム歩行器を使用するには、そのようなあなたのwp_nav_menu
の呼び出しを変更します。
wp_nav_menu(array(
'theme_location' => 'main_menu',
'items_wrap' =>'%3$s',
'container' => FALSE,
'walker' => new Custom_Button_Walker()
));
をあなたはおそらく、あなた自身の[メニューウォーカークラス](HTTPSを作成する必要があります。 //www.smashingmagazine.com/2015/10/customize-tree-like-data-structures-wordpress-walker-class/)。あなたが求めていることは、実際には些細なことではありません。 –