Filter hook that allows you to display or hide widget based on custom conditions.


function custom_rw_display_widget ($display, $instance) {
	if (is_category(1) && $instance['title'] == 'Your widget title') { // change Your widget title
		$display = true; // or false if you want to hide it
	return $display;
add_filter('rw_display_widget', 'custom_rw_display_widget', 10, 2);


  • $display | boolean – a boolean, to whether display a widget or not (true or false)
  • $instance | array – a widget instance to which true or false will be applied

4 replies to "rw_display_widget"

  1. How to use this filter to display one of widgets only for admins?
    What to include in function?

    • use something like this:

      if (current_user_can(manage_options) && $instance[‘title’] == ‘Your widget title’) { // change the title, manage_options is name of the capability that only administrators have

      • Thanks for advice. But I’m not programmer so I’ve switched to “Dynamic widgets” plugin which gives more possibilities without coding. Please consider it if you want to make your plugin better.

  2. I wanted to display a widget on only one post page so I needed to use an else statement with the above code to hide the widget on other pages.

    function using_page_break_widget ($display, $instance) {
    if (is_single(722) && $instance[‘title’] == ‘Using Page Break’) { // change Your widget title
    $display = true; // or false if you want to hide it
    else {
    if ($instance[‘title’] == ‘Using Page Break’) {
    $display = false;
    return $display;
    add_filter(‘rw_display_widget’, ‘using_page_break_widget’, 10, 2);

Leave a Reply

Please, do not use this form for technical support. To get support for our plugins, use the support forum.

Your email address will not be published.