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">'
                .'<ul class="dropdown-menu" style="list-style:none;" aria-labelledby="navbarDropdown">'
                .'<a href="#">'.'August 2018' .'</a>'
                .wp_get_archives( array('type' => 'monthly', 'format' => 'html', 'show_post_count' => $c))

      return $items;

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

Results: enter image description here

1 Answer 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.