WordPress.org

Forums

[resolved] Limit widgets to a number (3 posts)

  1. jbbrwcky
    Member
    Posted 5 years ago #

    Hi,

    After designing a theme I want to convert a horizontal content block to be widgetised. I then realised there is an issue - how do I limit the amount of widgets that someone can use/add? Also, how do I put in defaults if the blog owner doesn't select them, or if they only select say, two instead of three?

    Richard

  2. esmi
    Forum Moderator
    Posted 5 years ago #

    how do I limit the amount of widgets that someone can use/add?

    Ultimately, you can't. That's for the user to decide. The best you can do is to try and ensure that the horizontal block wraps over multiple lines. So - ok - it might look awful but if all of the text/links are readable and accessible, then I'd argue that, as a designer, you've done all you can do. At the end of the day, you cannot idiot-proof a theme.

    how do I put in defaults if the blog owner doesn't select them

    Place default content in there - e.g,:

    <?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Top Tabs') ) : ?>
    
    <?php wp_page_menu('show_home=1&menu_class=default-menu');?>
    
    <?php endif; ?>

    or if they only select say, two instead of three

    Widget default behaviour is to replace all default content as soon as a single widget is added. So if your design holds up with a single widget in place, again, you've done all you can do.

  3. jbbrwcky
    Member
    Posted 5 years ago #

    Hey Esmi,

    Yeah I thought that might be the case. Thanks though!

    Richard

Topic Closed

This topic has been closed to new replies.

About this Topic