我有wordpress + woocommerce网站,这是使用Divi主题。我使用自定义页面生成器构建的所有divi页面,但它不能用于post或singe-product.php页面。在大多数页面中,我使用divi builder(类似于短码元素)添加自定义菜单,我想将其添加到产品页面,但我不知道如何添加。
我试过了:
<?php echo do_shortcode('[et_pb_section admin_label=”Section” fullwidth=”on” specialty=”off”][et_pb_fullwidth_menu admin_label=”Fullwidth Menu” menu_id=”35″ background_color=”#ffffff” background_layout=”light” text_orientation=”left” submenu_direction=”downwards” fullwidth_menu=”off” dropdown_menu_animation=”fade”] [/et_pb_fullwidth_menu][/et_pb_section]
'); ?> 但我不知道为什么会显示主菜单(menu_id=“35”是自定义的)
我想到的另一个选择是数组( wp_nav_menu( 'menu‘=> '$custom') );但是我不知道如何将它包装到所有这些divi类中。
以下是菜单的html代码
<div class="et_pb_section et_pb_fullwidth_section et_pb_section_0 et_section_regular et_pb_scroll_0">
<div class="et_pb_fullwidth_menu et_pb_module et_pb_bg_layout_light et_pb_text_align_left et_dropdown_animation_fade et_pb_fullwidth_menu_0" style="background-color: #ffffff;" data-bg_color="#ffffff">
<div class="et_pb_row clearfix">
<nav class="fullwidth-menu-nav"><ul id="menu-xbox" class="fullwidth-menu nav downwards" style="background-color: rgb(255, 255, 255);"><li id="menu-item-222" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-222"><a href="http://gamehub.lt/xbox/xbox-one/">Xbox One</a></li>
<li id="menu-item-219" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-219"><a href="http://gamehub.lt/xbox/xbox-360/">Xbox 360</a></li>
<li id="menu-item-221" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-221"><a href="http://gamehub.lt/xbox/games/">Games</a></li>
<li id="menu-item-220" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-220"><a href="http://gamehub.lt/xbox/accessories/">Accessories</a></li>
</ul></nav>
<div class="et_mobile_nav_menu">
<a href="#" class="mobile_nav closed">
<span class="mobile_menu_bar"></span>
<ul id="mobile_menu1" class="et_mobile_menu" style="background-color: rgb(255, 255, 255);"><li id="menu-item-222" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-222 et_first_mobile_item"><a href="http://gamehub.lt/xbox/xbox-one/">Xbox One</a></li>
<li id="menu-item-219" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-219"><a href="http://gamehub.lt/xbox/xbox-360/">Xbox 360</a></li>
<li id="menu-item-221" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-221"><a href="http://gamehub.lt/xbox/games/">Games</a></li>
<li id="menu-item-220" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-220"><a href="http://gamehub.lt/xbox/accessories/">Accessories</a></li>
</ul></a>
</div>
</div>
</div>
</div>我是wordpress的新手,这是我使用它的第一个网站。菜单根据产品类别的不同而不同。下面是链接http://gamehub.lt/xbox/xbox-one/菜单one http://gamehub.lt/playstation/playstation-4-2/ another。
发布于 2016-06-23 14:03:10
您好,您可以直接粘贴的简短代码到header.php使用php做简短的代码,您可以获得所有页面上的菜单和隐藏的主题菜单。这是在所有页面上获取自定义菜单的最简单方法。
发布于 2018-01-06 21:10:35
抱歉,如果我不理解你的问题,但我所理解的是,你想要在你的主题中显示自定义菜单。
首先你需要在functions.php上注册一个导航菜单,你可以使用该代码来注册你的新菜单:
function register_my_menu() {
register_nav_menu('header-menu',__( 'Header Menu' ));
}
add_action( 'init', 'register_my_menu' );之后,您需要在主题标题中显示新菜单,您可以使用该代码:
<?php wp_nav_menu( array( 'theme_location' => 'header-menu' ) ); ?>https://stackoverflow.com/questions/35495556
复制相似问题