0
我正尝试在Wordpress网站上为单独的页面创建多个菜单。我希望主题加载主菜单,除非单个页面通过自定义字段指定不同的页面。Wordpress Header.php:为单独的页面创建多个菜单
试图将此代码添加到Header.php,但与主题自定义设置有问题,因为php没有“wp_nav_menu”。
<?php wp_nav_menu(array('container' => 'none', 'container_class' => 'menu-header', 'theme_location' => 'primary', 'menu' => get_post_meta($post->ID, 'MenuName', true))); ?>
当我直接将此代码添加到当前代码中时,它会导致主菜单在主题已经存在的自定义菜单的顶部加倍。这里是主题的header.php现有代码:
<?php do_action('presscore_body_top'); ?>
<div id="page"<?php if ('boxed' == of_get_option('general-layout', 'wide')) echo ' class="boxed"'; ?>>
<?php if (of_get_option('top_bar-show', 1)) : ?>
<?php get_template_part('templates/header/top-bar', of_get_option('top_bar-content_alignment', 'side')); ?>
<?php endif; // show top bar ?>
<?php if (apply_filters('presscore_show_header', true)) : ?>
<?php get_template_part('templates/header/header', of_get_option('header-layout', 'left')); ?>
<?php endif; // show header ?>
<?php do_action('presscore_before_main_container') ; ?>
<div id="main" <?php presscore_main_container_classes(); ?>><!-- class="sidebar-none", class="sidebar-left", class="sidebar-right" -->
<?php if (presscore_is_content_visible()): ?>
<div class="main-gradient"></div>
<div class="wf-wrap">
<div class="wf-container-main">
<?php do_action('presscore_before_content'); ?>
<?php endif; ?>
凡在此代码,我可以创建这个选项为各个页面拉一个单独的菜单吗?
我的问题在这里是理解在现有的header.php中放置此代码的位置。当我将它放在代码中时,它会导致第二个菜单加载到现有的顶部。如何在不加载重复菜单的情况下获取当前代码以注册此功能? 感谢您抽出时间帮助。 –