WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The Goal: To replace the sidebar on all sites across my network with content loaded from a plugin, across all themes.

I need a way of over-riding the sidebar/main widget area on all sites across my network.

I have written a plugin which generates the sidebar with a function call, but how can I get this content to completely replace the sidebar? At present I can only call a hook as get_sidebar() happens, not replace that action.

add_action('get_sidebar', 'my_get_sidebar', 11);

Additionally, this makes my sidebar appear on all sidebars on the page, I only want it to overwrite the main one (sidebar-one?) and have the others left blank.

share|improve this question

You should look into having your sidebars utilize the remove action function.

Then you can remove a sidebar and replace it in a function any number of ways.

For instance (this examples using a conditional based on a page called some-page.

function change_sidebar_yay() {
    if ( is_single('some-page') ) {
        remove_action( 'old_sidebar', 'your_function' ); //this is sidebar you want removed
        add_action('get_sidebar', 'my_get_sidebar', 11);


The old_sidebar and your_function is the name and the function name of the sidebar you want removed, you will have to look in your theme to find the actual values the theme author used ( usually in functions.php but not always).

Also if the theme is hardcoded or does not create sidebars using hooks/actions this will not work.

share|improve this answer
Could you define what 'old_sidebar' and 'your_function' should be? I essentially want to stop get_sidebar() – Dunhamzzz Apr 13 '11 at 15:09
Updated the answer to be more clear – Wyck Apr 13 '11 at 15:14
I need this to work across all themes, meaning I can't pick and choose from a theme file, is it impossible in this case? – Dunhamzzz Apr 13 '11 at 15:18
It's not impossible but you will have to create a network wide plugin, so it will effect all network themes even if they are different. – Wyck Apr 13 '11 at 16:16
That's exactly what I want, for i to happen network-wide, but all themes have different names for widgets so it will be impossible? – Dunhamzzz Apr 14 '11 at 8:56

not sure, but perhaps can the plugin Widget Logic be a good starting point to develop your function from?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.