-
AuthorPosts
-
November 29, 2015 at 11:25 am #682931
Hi Tim,
Please update the previous code a bit:
add_filter( 'wp_nav_menu_args', 'custom_blog_menu' ); function custom_blog_menu( $args ) { if ( is_singular( 'post' ) || is_archive() ) { $args['theme_location'] = 'primary'; $args['menu'] = 'Custom Menu'; } return $args; }
Let us know how it goes!
November 29, 2015 at 3:10 pm #683059Sorry, where does that code go within the _navbar.php file?
November 29, 2015 at 3:30 pm #683069Sorry, I just realized that there was other code that I didn’t see. I have not implemented anything through the functions.php file. I modified my _navbar.php file in the child theme with the following code. The menu is displaying correctly on the main posts page, but I need it to display the same alternate menu (Primary Blog) on all the related blog pages as well(archive, category, single-post).
<?php // ============================================================================= // VIEWS/GLOBAL/_NAVBAR.PHP // ----------------------------------------------------------------------------- // Outputs the navbar. // ============================================================================= $navbar_position = x_get_navbar_positioning(); $logo_nav_layout = x_get_logo_navigation_layout(); $is_one_page_nav = x_is_one_page_navigation(); ?> <?php if ( ( $navbar_position == 'static-top' || $navbar_position == 'fixed-top' || $is_one_page_nav ) && $logo_nav_layout == 'stacked' ) : ?> <div class="x-logobar"> <div class="x-logobar-inner"> <div class="x-container-fluid max width"> <?php x_get_view( 'global', '_brand' ); ?> </div> </div> <!-- end .x-logobar-inner --> </div> <!-- end .x-logobar --> <div class="x-navbar-wrap"> <div class="<?php x_navbar_class(); ?>"> <div class="x-navbar-inner"> <div class="x-container-fluid max width"> <?php if(is_home()): ?> <?php wp_nav_menu( array( 'menu' => 'Primary Blog', 'container' => false, 'menu_class' => 'x-nav sf-menu', ) ); ?> <?php else: ?> <?php x_get_view( 'global', '_nav', 'primary' ); ?> <?php endif; ?> </div> </div> <!-- end .x-navbar-inner --> </div> <!-- end .x-navbar --> </div> <!-- end .x-navbar-wrap --> <?php else : ?> <div class="x-navbar-wrap"> <div class="<?php x_navbar_class(); ?>"> <div class="x-navbar-inner"> <div class="x-container-fluid max width"> <?php x_get_view( 'global', '_brand' ); ?> <?php if(is_home()): ?> <?php wp_nav_menu( array( 'menu' => 'Primary Blog', 'container' => false, 'menu_class' => 'x-nav sf-menu', ) ); ?> <?php else: ?> <?php x_get_view( 'global', '_nav', 'primary' ); ?> <?php endif; ?> </div> </div> <!-- end .x-navbar-inner --> </div> <!-- end .x-navbar --> </div> <!-- end .x-navbar-wrap --> <?php endif; ?>
November 29, 2015 at 8:02 pm #683203Hi there,
You can change this line
<?php if(is_home()): ?>
to this,
<?php if( is_home() || is_archive() || is_singular('post') ): ?>
is_archive() represent all archive types such as category, tags, dates, etc.
Hope this helps.
April 26, 2016 at 10:30 am #900509At frist thanks for all the good support you guys are doing!
Im looking for a solution to change the menu based on mobile/desktop view. So basically I would like to show different menu items on mobile then I want on desktop.
I thought I could create to WP menus and show only the one for the right view. How can I do this?
Thanks a lot.
April 27, 2016 at 4:20 am #901725Hi there,
Thanks for writing in!
This isn’t something that out the box is offered by X, though you could try a plugin such as https://wordpress.org/plugins/mobile-menu/ but please note that we can’t guarantee it’s compatibility.
Thank you!
-
AuthorPosts