[wp-hackers] On theme switching pains

Manuel Schmalstieg webdev at ms-studio.net
Mon Nov 18 21:34:15 UTC 2013


Hi list,

Doing recently some instruction sessions with WP beginners, I am
wondering if we shouldn't improve the behavior of menus and widgets
when switching themes.

The issue: menus and widgets are systematically lost when switching themes.

What should happen IMHO: as long as the declared menu locations and
widget locations are the same (have the same ID), the settings should
be retained.

The same goes when switching from parent-theme to child-theme.
Currently, the menu connections are lost, which makes no sense to me.

Example:

Use the theme TwentyTwelve, which has a wp_nav_menu location named ‘primary’:

register_nav_menu( 'primary', __( 'Primary Menu', 'twentytwelve' ) );

Now, let’s create a menu, and assign it to the available area (Primary Menu).

Then, switch to TwentyThirteen which has the following menu location:

register_nav_menu( 'primary', __( 'Navigation Menu', 'twentythirteen' ) );

Ideal result:
Our menu should still be assigned to the “primary” location.

Actual result:
No menu is assigned to the “primary” location. Switching the theme has
broken the connection, which has to be done manually, and is pretty
confusing for beginners (who already have to figure out the nuance
between "a menu automatically generated from my pages" and a custom
menu that may or may not be assigned to the location).

Same goes for widgets. Shouldn't the widget-sidebar relationship be
maintained if the sidebar has the same ID?

If that was the case, themes could use a common ground for naming
those sidebars (main sidebar, footer...) and would be more compatible.
Much like it is the case with post formats.

Curious to hear opinions on this.
Manuel


More information about the wp-hackers mailing list