Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm woking on a chid theme for Ohsik. I'm trying to unregister a sidebar, but nothing is working

Here's my function.php child theme code:

function unregister_footer_sidebar() {
unregister_sidebar( 'sidebar-2' );
}
add_action( 'widgets_init','unregister_footer_sidebar',11);
add_action( 'widgets_init', 'ohsik_widgets_init',12);

What am I doing wrong? Any suggestions to solve the problem?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

This line is your problem

 add_action( 'widgets_init', 'ohsik_widgets_init', 12);

You are deregistering your sidebar correctly. For some reason you are registering it, or something. I don't see the need or use for this.

The other possibility that I'm thinking of for using this code is that somewhere you are registering your own custom sidebars.

If that is the case, you are most probably reusing the ID of the sidebar you have deregistered. Try changing the ID to 12 of your new sidebar. You can not reuse ID's. All ID's needs to be unique

share|improve this answer
    
You mean that I am de-registering and then re-registering it again? I tried to take off the last line, but the sidebar is still there... I didn't register any new sidebar, it's just the sidebar-1 and sidebar-2 coming from the parent theme –  fran p. Jun 5 at 9:43
    
I thought I had to recall the parent's theme widgets_init but I was wrong. The code without the last line works, as @Pieter suggested. –  fran p. Jun 5 at 9:52
    
Glad you got it working and learned something :). Enjoy –  Pieter Goosen Jun 5 at 10:24

Your Answer

 
discard

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.