【问题标题】:wordpress nav class id bug wp menuwordpress 导航类 id 错误 wp 菜单
【发布时间】:2015-03-24 10:24:41
【问题描述】:

大家好,wordpress 拒绝添加数组中指定的 id 和类,它会忽略代码,如果我检查元素,我会得到一堆 WordPress 类。有人可以帮忙吗?

(位置注册工作正常)

<div class="menu-main-nav-container">
<ul id="menu-main-nav" class="menu">
<li id="menu-item-110" class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-110">

//在functions.php中找到

function html5blank_nav()
{
    wp_nav_menu(
    array(
        'theme_location'  => 'header-menu',
        'menu'            => 'header-menu',
        'container'       => 'false',
        'container_class' => 'testclass',
        'container_id'    => 'testid',
        'menu_class'      => '',
        'menu_id'         => '',
        'echo'            => true,
        'fallback_cb'     => '',
        'before'          => '',
        'after'           => '',
        'link_before'     => '',
        'link_after'      => '',
        'items_wrap'      => '<ul>%3$s</ul>',
        'depth'           => 0,
        'walker'          => ''
        )
    );
}



    function register_html5_menu()
    {
        register_nav_menus(array( // Using array to specify more menus if needed
            'header-menu' => __('header-menu', 'html5blank'), // Main Navigation
        ));
    }

    add_action('init', 'register_html5_menu'); // Add HTML5 Blank Menu

header.php 中的代码(只是一个 sn-p)

get_header(); ?>

    <div id="primary" class="content-area">
        <main id="main" class="site-main" role="main">

        <?php if ( have_posts() ) : ?>

            <?php /* Start the Loop */ ?>
            <?php while ( have_posts() ) : the_post(); ?>
                <?php
                    get_template_part( 'content', get_post_format() ); 
                ?>

            <?php endwhile; ?>

            <?php the_posts_navigation(); ?>

            <?php html5blank_nav();?>  // call to NAV


    <a href="#" id="pull">Menu</a>  

【问题讨论】:

  • 你能把你用来调用菜单的代码贴出来吗?可能在 header.php 文件中。

标签: php wordpress class content-management-system nav


【解决方案1】:

您将容器设置为 false,因此您提供的类无处可去。

如果您想要容器上的类或为 menu_class 或 menu_id 指定类,请将 container 更改为 true。

【讨论】:

    【解决方案2】:

    你试过了吗?

    'items_wrap'      => '<ul id="%1$s" class="%2$s">%3$s</ul>',
    

    您应该将类​​放在menu_class 中,并将ID 放在menu_id 中以使其正常工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-16
      • 2012-09-18
      • 2019-09-08
      • 2017-03-30
      相关资源
      最近更新 更多