WP_GET_ARCHIVE不会从css或html生效

时间:2018-06-12 作者:Dejan Arsenijevic

我会尽量简短。因此,基本上我正在尝试将自定义项添加到我的菜单中,在本例中,这是带有months desc的归档下拉列表.wp_get_archives 也会忽略所有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);
结果:enter image description here

1 个回复
最合适的回答,由SO网友:Dejan Arsenijevic 整理而成

解决方案:“添加”echo\' => false, 到参数数组!“@bcworkz不同wp论坛

结束

相关推荐

定制器JS API:添加“Dropdown-Pages”控件

添加页面列表的正确方法是什么(type: dropdown-pages) 使用Customizer JS API?目前,我有此代码,但它不显示控件:api.control.add( new api.Control( \'custom-control\', { type: \'dropdown-pages\', section: \'custom-section\', setting: new wp.customize.Setting( \'custom-control\