#StackBounty: #php #wordpress #menu #wordpress-theming WordPress Swap Primary Menu from Menu

Bounty: 100

Scenario:

I want to faciliate the user to choose from two different menus to be used as his/her primary menu.

I created two menus, and an Entry in both menus to switch to each other (Switch to B) (Switch to A).

The idea is that when a menu item is pressed, a wordpress function is called to switch the menu. Since I have already created the menus, they have specific IDs to choose from. All I want to hook specific function on clicking the (menu entries created in each menu) to swap the primary menu.

Questions

How can I call the code on a menu?

Do I need any modification for this code?

add_filter( 'arrange_by_A', 'arrange_by_B');

function arrange_by_A( $args ) {
    if( $args['theme_location'] == 'primary') {
        $args['menu'] = '45';
    }
    return $args;
}

function arrange_by_B( $args ) {

    if( $args['theme_location'] == 'primary') {
        $args['menu'] = '65';
    }
    return $args;
}


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.