• I need to remove the primary side bar of my plugin and replace it with dynamic content – on a single page only –
    NB: I don’t want to modify any theme specific files such as functions.php or sidebar.php, I’m hoping there’s an action or filter hook capable of doing this.
    Thanks for your help!

Viewing 6 replies - 1 through 6 (of 6 total)
  • To do it on a specific page (if, in fact, it is the actual post-type ‘page’) you will need to create a Page Template.

    Thread Starter Arbiz

    (@arbiz)

    Hi
    Thanks for your reply but I’m trying to remove the sidebar from within a plugin so i can’t create a template page.
    Let me try to explain: the main plugin page includes some php code (linked to mysql). Depending on content received from database the sidebar should be removed and replaced. I was hoping there was a filter or action hook to do this from within my plugin page..

    Would it be possible to retrieve all registered sidebars’ ID with wp_get_sidebars_widgets() and the unregister them with unregister_sidebar( $id ) ?

    [EDIT]
    I gave it a quick test, it should work.

    $registered_sidebars = wp_get_sidebars_widgets();
    foreach( $registered_sidebars as $sidebar_name => $sidebar_widgets ) {
    	if( $sidebar_name != 'wp_inactive_widgets' ) unregister_sidebar( $sidebar_name );
    }
    Thread Starter Arbiz

    (@arbiz)

    Hi
    That sounded great…however when I run the code, my sidebar is still there…wp_get_sidebars_widgets() does return the list of widgets but unregister_sidebar() doesn’t seem to do anything.
    Did you actually manage to remove your sidebar using unregister_sidebar?
    Thanks for your help.

    Yeah, I managed to remove a sidebar I registred…

    Try placing this code at the end of theme’s functions.php. If it works there, it is probably also possible from within a plugin. Not sure, though.

    Thread Starter Arbiz

    (@arbiz)

    well that’s very strange, I’ve added the code in functions.php as suggested. Again the list of widgets is returned but the sidebar is not removed. I tested with twenty-eleven theme.
    I’m lost here…

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Remove sidebar’ is closed to new replies.