• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Change Primary Navigation with Page

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Change Primary Navigation with Page

This topic is: not resolved
  • This topic has 3 replies, 2 voices, and was last updated 10 years, 6 months ago by Susan.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • December 21, 2015 at 1:22 pm #174495
    kimberlymwhd
    Member

    Can you change the Primary Navigation menu for each individual Page?

    I tried this with Genesis Simple Menu and its only for Secondary Menu.

    I want to have 5 Custom Menus for 5 different Pages.

    Let me know if anyone can walk me through how to do this. Thanks!

    http://blog.fogelman-management.com/

    http://blog.fogelman-management.com/
    December 21, 2015 at 1:28 pm #174497
    Susan
    Moderator

    If you want to use the plugin, I would suggest switching out the location of the secondary menu for your primary menu, and voila, you can use that plugin 🙂

    Otherwise, you can hard code your functions.php file to display a different menu on different pages.

    December 21, 2015 at 1:38 pm #174503
    kimberlymwhd
    Member

    Susan, everything I read said no one would support changes like that.

    I see in the Plugin editor a bunch of things that say "gsm" assuming that means secondary? What would I change in there to make it primary?

    Here is the code for the Plugin:

    <?php
    /*
    Plugin Name: Genesis Simple Menus
    Plugin URI: http://www.studiopress.com/plugins/simple-menus
    Description: Genesis Simple Menus allows you to select a WordPress menu for secondary navigation on individual posts/pages.
    Version: 0.3.0.1
    Author: Ron Rennick
    Author URI: http://ronandandrea.com/
    Text Domain: genesis-simple-menus
    */
    /* Copyright: (C) 2010 Ron Rennick, All rights reserved.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    */

    /* Sample implementation of adding support for custom taxonomy

    add_filter( 'genesis_simple_menus_taxonomies', 'gsm_sample_taxonomy' );
    function gsm_sample_taxonomy( $taxonomies ) {
    $taxonomies[] = 'taxonomy-slug';
    return array_unique( $taxonomies );
    }
    */
    class Genesis_Simple_Menus {

    var $handle = 'gsm-post-metabox';
    var $nonce_key = 'gsm-post-metabox-nonce';
    var $field_name = '_gsm_menu';
    var $menu = null;
    var $taxonomies=null;
    /*
    * constructor
    */

    function __construct() {

    add_action( 'init', array( $this, 'init' ), 99 );

    load_plugin_textdomain( 'genesis-simple-menus', false, 'genesis-simple-menus/languages' );

    }
    /*
    * add all our base hooks into WordPress
    */
    function init() {

    if ( ! function_exists( 'genesis_get_option' ) )
    return;

    if ( ! genesis_nav_menu_supported( 'secondary' ) )
    return;

    add_action( 'admin_menu', array( $this, 'admin_menu' ) );
    add_action( 'save_post', array( $this, 'save_post' ), 10, 2 );
    add_action( 'wp_head', array( $this, 'wp_head' ) );

    $_taxonomies = get_taxonomies( array( 'show_ui' => true, 'public' => true ) );
    $this->taxonomies = apply_filters( 'genesis_simple_menus_taxonomies', array_keys( $_taxonomies ) );

    if ( empty( $this->taxonomies ) || ! is_array( $this->taxonomies ) )
    return;

    foreach( $this->taxonomies as $tax )
    add_action( "{$tax}_edit_form", array( $this, 'term_edit' ), 9, 2 );

    }
    /*
    * Add the post metaboxes to the supported post types
    */
    function admin_menu() {

    foreach( (array) get_post_types( array( 'public' => true ) ) as $type ) {

    if( $type == 'post' || $type == 'page' || post_type_supports( $type, 'genesis-simple-menus' ) )
    add_meta_box( $this->handle, __( 'Secondary Navigation', 'genesis-simple-menus' ), array( $this, 'metabox' ), $type, 'side', 'low' );

    }
    }
    /*
    * Does the metabox on the post edit page
    */
    function metabox() {
    ?>
    <p>
    <?php
    $this->print_menu_select( $this->field_name, genesis_get_custom_field( $this->field_name ), 'width: 99%;' );
    ?>
    </p>
    <?php
    }
    /*
    * Does the metabox on the term edit page
    */
    function term_edit( $tag, $taxonomy ) {

    // Merge Defaults to prevent notices
    $tag->meta = wp_parse_args( $tag->meta, array( $this->field_name => '' ) );
    ?>
    <h3><?php _e( 'Secondary Navigation', 'genesis' ); ?></h3>

    <table class="form-table">
    <tr class="form-field">
    <th scope="row" valign="top">
    <?php
    $this->print_menu_select( "genesis-meta[{$this->field_name}]", $tag->meta[$this->field_name], '', 'padding-right: 10px;', '</th><td>' ); ?>
    </td>
    </tr>
    </table>
    <?php
    }
    /*
    * Support function for the metaboxes, outputs the menu dropdown
    */
    function print_menu_select( $field_name, $selected, $select_style = '', $option_style = '', $after_label = '' ) {

    if ( $select_style )
    $select_style = sprintf(' style="%s"', esc_attr( $select_style ) );

    if ( $option_style )
    $option_style = sprintf(' style="%s"', esc_attr( $option_style ) );

    ?>
    <label for="<?php echo $field_name; ?>"><span><?php _e( 'Secondary Navigation', 'genesis-simple-menus' ); ?><span></label>

    <?php echo $after_label; ?>

    <select name="<?php echo $field_name; ?>" id="<?php echo $field_name; ?>"<?php echo $select_style; ?>>
    <option value=""<?php echo $option_style; ?>><?php _e( 'Genesis Default', 'genesis-simple-menus' ); ?></option>
    <?php
    $menus = wp_get_nav_menus( array( 'orderby' => 'name') );
    foreach ( $menus as $menu )
    printf( '<option value="%d" %s>%s</option>', $menu->term_id, selected( $menu->term_id, $selected, false ), esc_html( $menu->name ) );
    ?>
    </select>
    <?php
    }
    /*
    * Handles the post save & stores the menu selection in the post meta
    */
    function save_post( $post_id, $post ) {

    // don't try to save the data under autosave, ajax, or future post.
    if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return;
    if ( defined('DOING_AJAX') && DOING_AJAX ) return;
    if ( defined('DOING_CRON') && DOING_CRON ) return;
    if ( $post->post_type == 'revision' ) return;
    if ( isset( $_REQUEST['bulk_edit'] ) ) return;

    $perm = 'edit_' . ( 'page' == $post->post_type ? 'page' : 'post' ) . 's';
    if ( ! current_user_can( $perm, $post_id ) )
    return;

    if ( empty( $_POST[$this->field_name] ) )
    delete_post_meta( $post_id, $this->field_name );
    else
    update_post_meta( $post_id, $this->field_name, $_POST[$this->field_name] );

    }
    /*
    * Once we hit wp_head, the WordPress query has been run, so we can determine if this request uses a custom subnav
    */
    function wp_head() {

    add_filter( 'theme_mod_nav_menu_locations', array( $this, 'theme_mod' ) );

    if ( is_singular() ) {

    $obj = get_queried_object();
    $this->menu = get_post_meta( $obj->ID, $this->field_name, true );
    return;

    }

    $term = false;

    if ( is_category() && in_array( 'category', $this->taxonomies ) ) {

    $term = get_term( get_query_var( 'cat' ), 'category' );

    } elseif ( is_tag() && in_array( 'post_tag', $this->taxonomies ) ) {

    $term = get_term( get_query_var( 'tag_id' ), 'post_tag' );

    } elseif( is_tax() ) {

    foreach( $this->taxonomies as $tax ) {

    if( $tax == 'post_tag' || $tax == 'category' )
    continue;

    if( is_tax( $tax ) ) {

    $obj = get_queried_object();
    $term = get_term( $obj->term_id, $tax );
    break;

    }
    }
    }

    if ( $term && isset( $term->meta[$this->field_name] ) )
    $this->menu = $term->meta[$this->field_name];

    }
    /*
    * Replace the menu selected in the WordPress Menu settings with the custom one for this request
    */
    function theme_mod( $mods ) {

    if ( $this->menu )
    $mods['secondary'] = (int)$this->menu;

    return $mods;

    }
    }
    /*
    * giddyup
    */
    $gsm_simple_menu = new Genesis_Simple_Menus();

    December 21, 2015 at 3:48 pm #174511
    Susan
    Moderator

    everything I read said no one would support changes like that.

    I'm not sure why it would be an issue to change the location of your primary and/or secondary menu, since in some themes, support for the primary and secondary menus are completely removed anyway?

    I found a couple of posts on Brad Dalton's site (here) about a number of ways of accomplishing what you want to do.

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Change Primary Navigation with Page’ is closed to new replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble