• Access & Security 95
  • Administration 171
  • Advertisement 92
  • Audio & Video 66
  • Author & Content 99
  • Comments 96
  • Communication 110
  • Communities & Forums 84
  • Development 47
  • E-Commerce 76
  • Email Management 53
  • Events & Calendars 80
  • Language 25
  • Map & Weather 44
  • Migration & Conversion 28
  • Miscellaneous 254
  • Mobile 15
  • Photos 143
  • Plugins 260
  • SEO & Site Speed 118
  • Social 186
  • Theme Enhancement 169

  • Add this plugin to a List

    You need to be logged in to add this plugin to your list.

    Widget Logic

    Add to List

    This plugin gives every widget an extra control field called “Widget logic” that lets you control the pages that the widget will appear on. The text field lets you use WP’s Conditional Tags, or any general PHP code.

    PLEASE NOTE The widget logic you introduce is EVAL’d directly. Anyone who has access to edit widget appearance will have the right to add any code, including malicious and possibly destructive functions. There is an optional filter ‘widget_logic_eval_override’ which you can use to bypass the EVAL with your own code if needed. (See Other Notes).

    There is also an option to add a wordpress ‘widget_content’ filter — this lets you tweak any widget’s HTML to suit your theme without editing plugins and core code.


    If you like and use Widget Logic you could consider a small donation to Cancer Research UK. I have a donation link. As of February 2017 we have raised 1,048.50 UKP.

    Writing Logic Code

    The text in the ‘Widget logic’ field can be full PHP code and should return ‘true’ when you need the widget to appear. If there is no ‘return’ in the text, an implicit ‘return’ is added to the start and a ‘;’ is added on the end. (This is just to make single statements like is_home() more convenient.)

    The Basics

    Make good use of WP’s own conditional tags. You can vary and combine code using:

    • ! (NOT) to reverse the logic, eg !is_home() is TRUE when this is NOT the home page.
    • || (OR) to combine conditions. X OR Y is TRUE when either X is true or Y is true.
    • && (AND) to make conditions more specific. X AND Y is TRUE when both X is true and Y is true.

    There are lots of great code examples on the WP forums, and on WP sites across the net. But the WP Codex is also full of good examples to adapt, such as Test if post is in a descendent category.


    • is_home() — just the main blog page
    • !is_page('about') — everywhere EXCEPT this specific WP ‘page’
    • !is_user_logged_in() — shown when a user is not logged in
    • is_category(array(5,9,10,11)) — category page of one of the given category IDs
    • is_single() && in_category('baked-goods') — single post that’s in the category with this slug
    • current_user_can('level_10') — admin only widget
    • strpos($_SERVER['HTTP_REFERER'], "")!=false — widget to show when clicked through from a google search
    • is_category() && in_array($cat, get_term_children( 5, 'category')) — category page that’s a descendent of category 5
    • global $post; return (in_array(77,get_post_ancestors($post))); — WP page that is a child of page 77
    • global $post; return (is_page('home') || ($post->post_parent=="13")); — home page OR the page that’s a child of page 13

    Note the extra ‘;’ on the end where there is an explicit ‘return’.

    The ‘widget_logic_eval_override’ filter

    Before the Widget Logic code is evaluated for each widget, the text of the Widget Logic code is passed through this filter. If the filter returns a BOOLEAN result, this is used instead to determine if the widget is visible. Return TRUE for visible.

    The ‘widget_content’ filter

    When this option is active (tick the option tickbox at the foot of the widget admin page) you can modify the text displayed by ANY widget from your own theme’s functions.php file. Hook into the filter with:

    add_filter('widget_content', 'your_filter_function', [priority], 2);

    where [priority] is the optional priority parameter for the add_filter function. The filter function can take a second parameter (if you provde that last parameter ‘2’) like this:

    function your_filter_function($content='', $widget_id='')

    The second parameter ($widget_id) can be used to target specific widgets if needed.

    A WordPress filter function ‘takes as input the unmodified data, and returns modified data’ which means that widget_content filters are provided with the raw HTML output by the widget, and you are then free to return something else entirely:

    Example filters

    add_filter('widget_content', 'basic_widget_content_filter');
    function basic_widget_content_filter($content='')
    {   return $content."<PRE>THIS APPEARS AFTER EVERY WIDGET</PRE>";

    I was motivated to make this filter in order to render all widget titles with the excellent ttftitles plugin like this:

    add_filter('widget_content', 'ttftext_widget_title');
    function ttftext_widget_title($content='')
    {   preg_match("/<h2[^>]*>([^<]+)/",$content, $matches);
        $insert_img=the_ttftext( $heading, false );
        return $content;

    People often ask for a way to give widgets alternating styles. This filter inserts widget_style_a/widget_style_b into the class=”widget …” text usually found in a widget’s main definition:

    add_filter('widget_content', 'make_alternating_widget_styles');
    function make_alternating_widget_styles($content='')
    {   global $wl_make_alt_ws;
        return preg_replace('/(class="widget )/', "$1 widget_${wl_make_alt_ws} ", $content);
    Rate This Plugin

    Please Login to Rate this Plugin!




    0 Votes
    Not Rated Yet Stats

    Last Updated127 Days ago
    Published10 years ago

    Report Wrong Category!

    Do you think this Plugin belongs to another Category?

    What Category Should this Plugin belong to? *

    Reason *

    Create a Plugin List

    You need to be Logged in to Create a Plugin List.

    Submit A plugin

    You need to be logged in to submit a plugin.


    WPD is the unofficial online plugin directory of WordPress.

    An attempt has been made to list Only functional, active,efficient and up-to-date plugins.

    Categorized : Plugin are listed by category and subcategory based on functionality and uses. Here you can browse wordpress plugin from our neatly categorized plugin directory and sort the plugins by rating, votes, last updated and published and search plugins using tags.

    Search : Plugins can be searched by their functionality using multi-tag search and you can search plugins using their exact name although we are not ensuring Google like search accuracy.

    Create Plugin Lists : You will be able to create list of plugins and share them with Wordpress Community or you can keep them private and use them as a bookmarks.
    e.g. Plugins That I’ve Used on My Site, Best Event Management Plugins, Christmas Plugins etc.

    If you think certain awesome plugin is not in the directory then notify us through our Submit a Plugin page.

    Browsing the Plugin Directory

    Browse by Category

    In WPD, Plugins are categorized carefully. You can browse all the categories from the homepage or you can access the category lists from any page by clicking the button from the left of the website.

    Browse by Tags

    Each plugin listed in WPD is marked with useful tags. You can browse plugins by Tags from the All Tags page

    Searching in WPD

    Multi Tag Search

    You can search plugins using multiple tags. To perform a multi-tag search. Go to Homepage and then in the search field type any keywords or tags(comma separated) and then click on the search button. To search plugins from a selected category just select the category from the dropdown and type your tags.

    Searching a specific Plugin in WPD

    If you want to find a specific plugin in our directory, Go to Homepage and then select the "Search in Title" option. Then write the name of the plugin and click the search button to find the Plugin.

    Plugin Lists

    Whats a Plugin List

    Plugin Lists are user created lists of plugins. Any registered users can create Plugin Lists and share it with anyone or make it private.

    Why Create a plugin List?
    • Easy to keep track of your favourite and useful plugin.

    • Share list of plugins on blogs, social media or to a client.

    • Keep a track of what plugins you installed in which of your blogs by creating a list for each blog

    Creating a Plugin List

    To create a Plugin List, click the button from the left of the page; a popup box will appear. In the "List Name" field, put the name of the List. eg: Best Seo plugins for your site.
    In the Description field, put a few words describing the List.
    By default, lists are automatically published as public, which is visible to everyone. If you do not want others to see the List, select "Private" from the dropdown list. Then click the "Create List" button to create the list.

    Adding Plugins to your List

    To add a plugin to your List, go to a plugin page and click the "Add to List" button. A popup box will appear where you can select in which of your list you want to add this plugin. You can add a note if you want, this note will appear below the plugin in your list.
    P.S: You can only add plugins that are in our directory.

    Your Lists will appear in our "Plugin Lists" page when you set the list as "Public" and your list contains atleast 2 plugins.

    Editing your Lists

    When you are on your list page, notice there is a button on the top right corner of the page. Click it to edit the List Name and the List Description.

    Accessing All your Lists

    You can access all your Plugin lists by going to your profile and clicking the "Lists" tab.

    Removing your Lists

    You can remove your Plugin lists by going to your profile and clicking the "Lists" tab. on top right of each list click the button to remove the list completely.

    While tremendous effort has been put to keep this directory precise and complete, still errors and omissions are unavoidable and possible. We welcome any suggestions for corrections, deletions, and idea that might improve the overall experience.

    To submit a Feedback click the from the bottom right corner of the site.

    Register or log in to assess the record