开发者

wp_nav_menu change sub-menu inline style?

I am trying to modify sub-menus of a Wordpress site. Wordpress generates the following HTML code for the sub-menus

<ul class="sub-menu" style="top: 50px; visibility: visible; left: 0px; width: 202px; display: none;">
    <li class="menuitem123 menu-item menu-item-type-post_type menu-item-object-page menu-item-123" id="menu-item-123"><a href="http://www.example.com" class="">Link Name</a></li>
        <!-- other li elements follow -->
</ul> 

Here's my invocation of the wp_nav_menu

<?php if(has_nav_menu('secondary')):?>
    <?php wp_nav_menu( array( 'sort_column' => 'menu_order', 'menu_container' => 'div', 'container_id' => 'secondary-menu','menu_class' => '',  'theme_location' => 'secondary'));?>
<?php endif;?>

The problem is, I want to customize the inline style (or preferably move it out into a css file) that Wordpress is generating for the ul element, mainly the width. I have searched high and low but cannot find from where Wordpress is picking up the inline style and inserting it. I need to get开发者_开发问答 rid of the inline style because I need to set different width for other sub-menus.

I could adapt the answer given on this wp_nav_menu change sub-menu class name? link which suggests sub classing the Wordpress Walker class.

Please can someone provide some pointers on what else should I be checking to see from where Wordpress is picking up the inline style?

Many thanks.


WordPress itself does not generate any inline styles, so most probably the deal is in your plugins or theme installed. According to your code, you do not use customized walkers, so the only deal may be in filters attached to standard Walker_Nav_Menu (see nav-menu-template.php file, at the beginning). Corresponding filters are most probably: nav_menu_css_class, nav_menu_item_id, walker_nav_menu_start_el.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜