Notice: These forums are now retired and closed. For active support, please Submit a Ticket or visit our official WordPress.org community pages.
Kadence Theme | Kadence Blocks | Starter Templates | WooCommerce Email Designer | Ascend | Virtue | Pinnacle
Custom Header Or Menu On Specific Pages
Home / Forums / Kadence Theme / Custom Header Or Menu On Specific Pages
- This topic has 2 replies, 2 voices, and was last updated 5 years, 6 months ago by
Ben Ritner.
Hi Ben and team. I am wanting a different menu depending on the page the user is viewing. I will include code below on how we did it via Beaver Build in case it helps, but am wondering if there is ay way with Kadence Theme to do it via a custom header/menu only on certain pages that does not require custom code. If not, no worries, but thought I would check. Thanks.
One idea would be to maybe use elements and then load the menu as an element on certain pages and disable the normal menu via the page settings. Is that a good idea? Any performance concerns vs custom PHP?
`<?php
/**
* Helper class for theme functions.
*
* @class FLChildTheme
*/
final class FLChildTheme {
/**
* @method styles
*/
static public function stylesheet() {
$css_ver = filemtime( get_stylesheet_directory() . ‘/style.css’ );
echo ‘<link rel=”stylesheet” href=”‘ . FL_CHILD_THEME_URL . ‘/style.css?ver=’ . $css_ver . ‘” />’;
}
/**
* Renders the markup for the fixed header.
*
* @since 1.0
* @return void
*/
static public function fixed_header() {
// Prevet showing fixed header on the Logo Page tempale
if ( is_page_template( ‘page-templates/page-logo.php’ ) ) {
return;
}
$header_layout = FLTheme::get_setting( ‘fl-fixed-header’ );
$header_enabled = apply_filters( ‘fl_fixed_header_enabled’, true );
if ( ‘visible’ == $header_layout && $header_enabled ) {
get_template_part( ‘includes/fixed-header’ );
}
}
/**
* Renders the markup for the main header.
*
* @since 1.0
* @return void
*/
static public function header_layout() {
$header_layout = FLTheme::get_setting( ‘fl-header-layout’ );
$header_enabled = apply_filters( ‘fl_header_enabled’, true );
if ( ‘none’ != $header_layout && $header_enabled ) {
if ( is_page( array( ‘cart’, ‘checkout’ ) ) ) {
get_template_part( ‘includes/nav-without’ );
} else {
get_template_part( ‘includes/nav-‘ . $header_layout );
}
}
}
/**
* Regiser the menu in the main header.
*
* @since 1.0
* @return void
*/
static public function register_menus() {
unregister_nav_menu( ‘header’ );
register_nav_menus( array(
‘back-to-top’ => esc_html__( ‘Back-To-Top Menu’, ‘bb-theme-5dd’ ),
) );
register_nav_menus( array(
‘customer’ => esc_html__( ‘Customer Menu’, ‘bb-theme-5dd’ ),
) );
register_nav_menus( array(
‘sale’ => esc_html__( ‘Sale Menu’, ‘bb-theme-5dd’ ),
) );
register_nav_menus( array(
‘non-sale’ => esc_html__( ‘Non-Sale Menu’, ‘bb-theme-5dd’ ),
) );
register_nav_menus( array(
‘affiliate’ => esc_html__( ‘Affiliate Menu’, ‘bb-theme-5dd’ ),
) );
register_nav_menus( array(
‘sale-party’ => esc_html__( ‘Sale Menu – Party Page’, ‘bb-theme-5dd’ ),
) );
}
/**
* Renders the menu in the main header.
*
* @since 1.0
* @return void
*/
static public function header_menus() {
$header_layout = FLTheme::get_setting( ‘fl-header-layout’ );
if ( is_page_template( ‘page-templates/page-logo.php’ ) ) {
/*
* If page template is “Logo Page”, show no menu
* @since 1.0
*/
return;
}
elseif ( is_page( array(
52426, // affiliate-area/about
)
)
) {
wp_nav_menu( array(
‘theme_location’ => ‘back-to-top’,
‘items_wrap’ => ‘<ul id=”%1$s” class=”nav navbar-nav ‘ .
( ‘right’ === $header_layout ? ‘navbar-right’ : ” ) . ‘ %2$s”>%3$s</ul>’,
‘container’ => false,
‘fallback_cb’ => ‘FLTheme::nav_menu_fallback’,
) );
}
elseif ( is_page( array(
115611, // vcb-iii-party
115882, // vcb-iii-kickstart
142873, // vcb-iv-party
147539, // vcb-iv-sumo
)
)
) {
wp_nav_menu( array(
‘theme_location’ => ‘sale-party’,
‘items_wrap’ => ‘<ul id=”%1$s” class=”nav navbar-nav ‘ .
( ‘right’ === $header_layout ? ‘navbar-right’ : ” ) . ‘ %2$s”>%3$s</ul>’,
‘container’ => false,
‘fallback_cb’ => ‘FLTheme::nav_menu_fallback’,
) );
}
elseif ( is_page( array(
142766, // vcb-iv-kickstart
)
)
) {
wp_nav_menu( array(
‘theme_location’ => ‘blank-menu’,
‘items_wrap’ => ‘<ul id=”%1$s” class=”nav navbar-nav ‘ .
( ‘right’ === $header_layout ? ‘navbar-right’ : ” ) . ‘ %2$s”>%3$s</ul>’,
‘container’ => false,
‘fallback_cb’ => ‘FLTheme::nav_menu_fallback’,
) );
}
elseif ( is_page(
/*
* If page slug is in array, use ‘customer’ navigation menu
* @since 1.0
*/
array(
52266, // my-account
52475, // my-account/faqs/
)
)
) {
wp_nav_menu( array(
‘theme_location’ => ‘customer’,
‘items_wrap’ => ‘<ul id=”%1$s” class=”nav navbar-nav ‘ .
( ‘right’ === $header_layout ? ‘navbar-right’ : ” ) . ‘ %2$s”>%3$s</ul>’,
‘container’ => false,
‘fallback_cb’ => ‘FLTheme::nav_menu_fallback’
) );
}
elseif ( is_page(
/*
* If page slug is in array, use ‘affiliate’ navigation menu
* @since 1.0
*/
array(
38, // affiliate-area
52480, // entry
52456, // affiliate-area/contact/
52473, // affiliate-area/faqs/
52434, // affiliate-area/products/
60177, // affiliate-area/resources/
88825, // my-profile
142212, // affiliate-area/resources/smart-goals/
124419, // affiliate-area/products/
217193, // affiliate-area/resources/difference-makers/
217585, // partner-onboarding-2/
216459, //partner-onboarding/
)
)
|| ‘contributor’ === get_post_type()
) {
wp_nav_menu( array(
‘theme_location’ => ‘affiliate’,
‘items_wrap’ => ‘<ul id=”%1$s” class=”nav navbar-nav ‘ .
( ‘right’ === $header_layout ? ‘navbar-right’ : ” ) . ‘ %2$s”>%3$s</ul>’,
‘container’ => false,
‘fallback_cb’ => ‘FLTheme::nav_menu_fallback’
) );
}
elseif ( is_page(
/*
* If page slug is in array, use ‘sale’ navigation menu
* @since 1.0
*/
array(
52353, // iii
52533, // bb-i
52829, // bb-i-1
52910, // bb-i-2
52958, // bb-i-3
52981, // bb-i-4
53001, // bb-i-5
)
)
) {
wp_nav_menu( array(
‘theme_location’ => ‘sale’,
‘items_wrap’ => ‘<ul id=”%1$s” class=”nav navbar-nav ‘ .
( ‘right’ === $header_layout ? ‘navbar-right’ : ” ) . ‘ %2$s”>%3$s</ul>’,
‘container’ => false,
‘fallback_cb’ => ‘FLTheme::nav_menu_fallback’
) );
}
else {
wp_nav_menu( array(
/*
* If page slug is not above, use ‘non-sale’ menu
* @since 1.0
*/
‘theme_location’ => ‘non-sale’,
‘items_wrap’ => ‘<ul id=”%1$s” class=”nav navbar-nav ‘ .
( ‘right’ === $header_layout ? ‘navbar-right’ : ” ) . ‘ %2$s”>%3$s</ul>’,
‘container’ => false,
‘fallback_cb’ => ‘FLTheme::nav_menu_fallback’
) );
}
}
}`
- The forum ‘Kadence Theme’ is closed to new topics and replies.


