Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1194644

    jgar246
    Participant

    Hi there,

    I would like to set my blog page (news) to have a custom menu. I am using menu swapper throughout the site, however, it does not work on the blog page.

    Could you please advise on how I can accomplish this?

    Please see site details in response below.

    #1194649

    jgar246
    Participant
    This reply has been marked as private.
    #1194952

    Rue Nel
    Moderator

    Hello There,

    Thanks for writing in! What you are trying to accomplish requires a template customization, we would like to suggest that you use a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.

    After the child theme is set up, please add the following code in your child theme’s functions.php file

    // Custom menu in Blog index
    // =============================================================================
    add_filter( 'wp_nav_menu_args', 'custom_blog_menu' );
    
    function custom_blog_menu( $args ) {
      if ( is_home() ) {
        $args['theme_location'] = 'primary';
        $args['menu'] = 'Blog Menu';
      }
      return $args;
    }
    // =============================================================================

    The code will swap the menu for the blog index. Just make sure that you have supplied the correct name for the 'Blog Menu'. I think you will need to create another menu in Appearance > Menu.

    Please let us know if this works out for you.

    #1195819

    jgar246
    Participant

    I created a new menu and used the Code Snippets plugin to input the code; it worked like a charm… Thanks for the help

    #1195937

    Joao
    Moderator

    Glad to hear it,

    Joao