0

I'll try to keep it short. So basically I'm trying to add custom item to my menu which in this case is the archive dropdown list with months desc. Everything looks nice and clean but the output of .wp_get_archives which also ignores all of the css

function add_archive_dropdown($items, $args) {
      if( $args->theme_location == 'primary' ){
      $items .='<li class="nav-item dropdown">'
                .'<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">'
                  .'Archive'
                .'</a>'
                .'<ul class="dropdown-menu" style="list-style:none;" aria-labelledby="navbarDropdown">'
                .'<li>'
                .'<a href="#">'.'August 2018' .'</a>'
                .'</li>'
                .'<li>'
                .wp_get_archives( array('type' => 'monthly', 'format' => 'html', 'show_post_count' => $c))
                .'</li>'
                .'</ul>'
                .'</li>';
      }


      return $items;
}

add_filter('wp_nav_menu_items', 'add_archive_dropdown', 10, 2);

Results: enter image description here

1 Answer 1

1

Solution : "Add 'echo' => false, to the arguments array!" by @bcworkz different wp forum

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.