Answer the question
In order to leave comments, you need to log in
How to add function output to wordpress menu properties?
Hello! There is a menu in wordpress in which I want to include the last item li in the result of displaying the value of the dynamic sidebar"crypto_currency" );
dynamic_sidebar(
<nav id="secondary-navigation" class="main-navigation secondary-navigation" role="navigation">
<?php if ( has_nav_menu( 'secondary' ) ) {
wp_nav_menu( array(
'theme_location' => 'secondary',
'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>';
) );
} ?>
<span><?php dynamic_sidebar( "crypto_currency" ); ?></span>
</nav><!-- .secondary-navigation -->
<nav id="secondary-navigation" class="main-navigation secondary-navigation" role="navigation">
<?php if ( has_nav_menu( 'secondary' ) ) {
$items_wrap =
wp_nav_menu( array(
'theme_location' => 'secondary',
'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</li>'+dynamic_sidebar( "crypto_currency" )+'</li></ul>'
) );
} ?>
</nav><!-- .secondary-navigation -->
Answer the question
In order to leave comments, you need to log in
somehow so
add_filter( 'wp_nav_menu_items', 'wpp_add_menu_item', 10, 2 );
function wpp_add_menu_item ( $items, $args ) {
if ($args->theme_location == 'secondary') {
ob_start();
dynamic_sidebar( "crypto_currency" );
$item = ob_get_clean();
$items .= sprintf('<li>%s</li>',$item);
}
return $items;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question