WordPress – Only allow one Text Widget to be added

I’m in the process of trying to create a custom theme for WordPress and managed to create a working widget area. But for the purpose of this theme, I would like to allow only one “Text-Widget” to be used. How would I go about limiting this?

Related posts

Leave a Reply

2 comments

  1. Can you provide urls so we could advice a solution to you?
    I’ll update the code below to be compatible with your theme if you can give a url to your blog.

    WordPress don’t allow you to limit the number of widgets but you can use javascript to hide the next sidebar items.

    $('.sidebar li:gt(0)').hide();
    

    the 2nd list item onwards will be hidden.

    and yeah, this is a bit of cheating though.
    SEO wise the next widgets are still visible.