- This topic has 5 replies, 2 voices, and was last updated 11 years, 5 months ago by
Sakin.
-
AuthorPosts
-
May 14, 2014 at 1:37 am #30462
kteschmitt
MemberHi all,
I’m using the Catch Box Free theme and trying to make the secondary menu appear on only a few pages. Does anyone know how I might go about doing this? I can’t provide a link to my site unfortunately because it isn’t live yet. Any general advice would be helpful!
May 14, 2014 at 11:13 am #30513Sakin
Keymaster@kteschmitt: The option will be to build child theme and then create
functions.phpfile in your child theme and copy the functioncatchbox_header_menuin your child themefunctions.phpfile edit the condition is_page.May 15, 2014 at 10:07 pm #30813kteschmitt
MemberThanks for responding! I copied the
catchbox_header_menufunction into my child theme’s functions.php file but I’m not sure exactly how to write the echo part. This is what I have so far:<?php if ( is_page('375, 333, 327, 381, 335')) { echo '<nav id="access-secondary">What goes here?</nav>'; } ?>May 16, 2014 at 1:59 am #30857Sakin
Keymaster@kteschmitt: Ok here is the code. You just need to create empty functions.php file in your child theme and then add the following code.
<?php /** * Catch Box Child Theme functions and definitions * */ /** * Header Menu * * @since Catch Box 2.5 */ function catchbox_header_menu() { ?> <nav id="access" role="navigation"> <h3 class="assistive-text"><?php _e( 'Primary menu', 'catchbox' ); ?></h3> <?php /* Allow screen readers / text browsers to skip the navigation menu and get right to the good stuff. */ ?> <div class="skip-link"><a class="assistive-text" href="#content" title="<?php esc_attr_e( 'Skip to primary content', 'catchbox' ); ?>"><?php _e( 'Skip to primary content', 'catchbox' ); ?></a></div> <div class="skip-link"><a class="assistive-text" href="#secondary" title="<?php esc_attr_e( 'Skip to secondary content', 'catchbox' ); ?>"><?php _e( 'Skip to secondary content', 'catchbox' ); ?></a></div> <?php /* Our navigation menu. If one isn't filled out, wp_nav_menu falls back to wp_page_menu. The menu assiged to the primary position is the one used. If none is assigned, the menu with the lowest ID is used. */ ?> <?php if ( has_nav_menu( 'primary', 'catchbox' ) ) { $args = array( 'theme_location' => 'primary', 'container_class' => 'menu-header-container', 'items_wrap' => '<ul class="menu">%3$s</ul>' ); wp_nav_menu( $args ); } else { echo '<div class="menu-header-container">'; wp_page_menu( array( 'menu_class' => 'menu' ) ); echo '</div>'; } ?> </nav><!-- #access --> <?php if ( has_nav_menu( 'secondary' ) && is_page(array('375', '333', '327', '381', '335' ) ) ) { // Check is footer menu is enable or not $options = catchbox_get_theme_options(); if ( !empty ($options ['enable_menus'] ) ) : $menuclass = "mobile-enable"; else : $menuclass = "mobile-disable"; endif; ?> <nav id="access-secondary" class="<?php echo $menuclass; ?>" role="navigation"> <h3 class="assistive-text"><?php _e( 'Secondary menu', 'catchbox' ); ?></h3> <?php /* Allow screen readers / text browsers to skip the navigation menu and get right to the good stuff. */ ?> <div class="skip-link"><a class="assistive-text" href="#content" title="<?php esc_attr_e( 'Skip to primary content', 'catchbox' ); ?>"><?php _e( 'Skip to primary content', 'catchbox' ); ?></a></div> <div class="skip-link"><a class="assistive-text" href="#secondary" title="<?php esc_attr_e( 'Skip to secondary content', 'catchbox' ); ?>"><?php _e( 'Skip to secondary content', 'catchbox' ); ?></a></div> <?php wp_nav_menu( array( 'theme_location' => 'secondary', 'container_class' => 'menu-secondary-container' ) ); ?> </nav> <?php } }May 16, 2014 at 3:22 am #30885kteschmitt
MemberThank you so much! And thanks for making the beautiful theme!
May 16, 2014 at 12:31 pm #30950Sakin
Keymaster@kteschmitt: Thanks for your appreciation. Cheers 🙂
-
AuthorPosts
- The topic ‘Secondary menu conditionals’ is closed to new replies.
