1
votes

Coming from a Joomla background one of the fist things I realised is that Wordpress 3 doesn't have native support for controlling the visibility of widgets (modules in Joomla).

I've tried:

Can anybody recommend a solution?

5
Do you want for example to display a text only for admins or editors (level)? - Vlad.P
That would be useful. But what I really need is the ability to set a widget to display on page-a but not display on page-b. - Dylan Spencer James

5 Answers

1
votes
1
votes

You can use Display Widgets. It adds checkboxes to each widget to either show or hide it on every site page: http://wordpress.org/extend/plugins/display-widgets/screenshots/

Make sure to disable other similar plugins to avoid conflict.

0
votes

Example from sidebar.php:

<div class="sidebar-box border-radius-6px">
    <h2>Dream Categories</h2>
    <ul>
        <?php wp_list_categories('title_li='); ?>
    </ul>
</div><!-- Sidebar Box End -->

Lets say you want to display this only on a page called "about-us". use is_page() function provided by wordpress.

<?php if(is_page('about-us')) { ?>
<div class="sidebar-box border-radius-6px">
        <h2>Dream Categories</h2>
        <ul>
            <?php wp_list_categories('title_li='); ?>
        </ul>
    </div><!-- Sidebar Box End -->
<?php } ?>

And as for the user level:

<?php if(current_user_can('level_10')) { // Level 10 = Administrator ?> 
<div class="sidebar-box border-radius-6px">
    <h2>Dream Categories</h2>
        <ul>
            <?php wp_list_categories('title_li='); ?>
        </ul>
</div><!-- Sidebar Box End -->
<?php } ?>

Please see Wordpress User Levels

PS: I saw the plugin provided by aendrew and I had a look at it. Try this: Make a backup of widget_login.php file then open it, search for line 75 and replace it with update_option("widget_logic", "is_page('" . $wl_options . "')"); This should easy up the stuff a little, when you limit a widget you have to add is_page('bla-bla') in that input that line should only require bla-bla (If the page is called Bla Bla) [not tested, but you can give it a try.]

0
votes
0
votes

For anyone still looking for a plugin for this purpose, check out my plugin Widget Visibility.

It's user friendly (uses checkboxes) and works inside the WordPress customizer too.