Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #30462
    kteschmitt
    Member

    Hi 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!

    #30513
    Sakin
    Keymaster

    @kteschmitt: The option will be to build child theme and then create functions.php file in your child theme and copy the function catchbox_header_menu in your child theme functions.php file edit the condition is_page.

    #30813
    kteschmitt
    Member

    Thanks for responding! I copied the catchbox_header_menu function 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>';
    }
    ?>
    #30857
    Sakin
    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 }
    }
    #30885
    kteschmitt
    Member

    Thank you so much! And thanks for making the beautiful theme!

    #30950
    Sakin
    Keymaster

    @kteschmitt: Thanks for your appreciation. Cheers 🙂

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Secondary menu conditionals’ is closed to new replies.