Widget Ninja: Make widgets display where you want them

Things to Know

  • GUI: Graphical User Interface.  A software interface designed to standardize and simplify the use of computer programs.
  • Logical Statement:  A logical statement is a complete thought that is either true or false.
  • Example: It is raining.  This statement can be determined to be true or false.
  • Tags: In WidgetNinja, tags (e.g., is_home, is_front_page, see list below) are used to create logical statements.  Example: is_home can be evaluated to be true or false
  • Conditional Statement:  Or an "if-then" statement, tests a logical statement and based on the result (true or false) performs some action or task.  There are several varieties of Conditional Statements.  Examples:
  • IF-THEN:  IF ("It is raining" = True) THEN {Take an umbrella.}
  • IF-THEN-ELSE:  IF ("It is raining" = True) THEN {Take an umbrella.} ELSE {Do not take an umbrella.}
  • IF-THEN-ELSE IF:  IF ("It is raining" = True) THEN {Take an umbrella.} ELSE IF ("It is sunny." = True) THEN {Wear a hat.}
An IF clause can test multiple logical statements using the AND, OR and NOT operators.  Examples:

  • AND:  IF ("It is raining." = True AND "It is lightning." = True) THEN {Wear a raincoat.}
  • OR: IF ("It is raining." = True OR "It is snowing." = True) THEN {Wear rubber boots.}
  • NOT: IF ("It is NOT raining" AND "It is NOT snowing." AND "It is NOT cold.") THEN {Wear shorts and a T-shirt.}



Usage


Widget Ninja allows widgets to be displayed on certain pages and not displayed on other pages based on "conditional tags."  Widget Ninja’s GUI can be found on the bottom of every Widget's GUI. 



Options look the same for every widget. Please don’t forget to
 click “Save” after making changes to widget’s settings.

Main settings

Main settings are used to determine the logical operator Ninja uses for that widget, or to completely disable Ninja (for that widget).


  • First Option: if Widget Ninja is disabled the widget will be shown on all pages
  • Second Option: logical “or” operator will show the widget if any conditional tag returns true
  • IF (is_search = True OR is_404 = True)THEN {Widget will be displayed.}
  • Third Option: logical “and” operator will show the widget only if all conditional tags return true
  • IF (is_front_page = True AND is_category = True)THEN{Widget wil be displayed.}
  • Fourth Option: logical “not” displays the widget only if all conditional tags return false
  • IF (is_front_page = False AND is_home = False){Widget will be displayed.}

Creating logical statements with conditional tags

You can use 22 tags (8 can have additional parameters configured) to create logical statements. Only tags in the “active conditional tags” box are part of the statement. Ones in the box below are disabled.  Simply drag the conditional tag from one to the other to activate or deactivate it.  Tag order is irrelevant and does not affect the end result of conditional testing. Each tag returns only true (1) or false (0) values. Additional tag parameters are configured by clicking the “Options” icon on the tag.
Detailed in-line help is available for every tag by clicking its “Help” icon.


Configuring Additional Parameters


Click the "Options" icon on the conditional tag.



A new window will appear with the options that can be selected for that tag.


Select the desired options and click 'Ok."


List of Conditional Tags

is_home
Additional options available: no.
Checks if the main page is being displayed. If you select a static page as your front page then use is_front_page.
See is_home description on WordPress Codex.

is_front_page
Additional options available: no.
Checks if the main page is a post or a page. It returns true when the main blog page is being displayed and the Settings-Reading-Front page displays is set to “Your latest posts”, or when is set to “A static page” and the “Front Page” value is the current page being displayed.
See is_front_page description on WordPress Codex.

is_category
Additional options available: yes.
Checks if a category archive page is being displayed. If you define specific category (or categories using options icon) it will check only for that category.
Should not be confused with in_category.
See is_category description on WordPress Codex.

in_category
Additional options available: yes.
Checks if the current post is assigned to any of the specified categories (use options icon to select categories).
Tag considers only the categories a post is directly assigned to, not the parents of the assigned categories.
See in_category description on WordPress Codex.

is_tag
Additional options available: yes.
Checks if a tag archive page is being displayed. Use options icon to select specific tags you want to check for.
Should not be confused with has_tag.
See is_tag description on WordPress Codex.

has_tag
Additional options available: yes.
Check if the current post has any of the given tags (use options icon to choose tags). If no tags are given, determines if post has any tags.
See has_tag description on WordPress Codex.

is_tax
Additional options available: yes.
Checks if a custom taxonomy archive page is being displayed. You should use is_category() and is_tag()respectively when checking for category and tag archives.
See is_tax description on WordPress Codex.

is_404
Additional options available: no.
Checks if a 404 error page is being displayed.
See is_404 description on WordPress Codex.

is_page
Additional options available: yes.
Checks if a page is being displayed (use options icon to choose which pages you want to test for). If no pages are defined it determines if any page is displayed.
See is_single if you want to test if a single post is being displayed.
See is_page description on WordPress Codex.

is_single
Additional options available: yes.
Checks if a single post is being displayed (use options icon to choose which posts you want to test for). If no posts are defined it determines if any post is displayed.
See is_page if you want to test if a single page is being displayed.
See is_single description on WordPress Codex.

is_sticky
Additional options available: no.
Checks if “Stick this post to the front page” check box has been checked for the current post.
Click options icon if you want to test “stickiness” for posts other than current.
See is_sticky description on WordPress Codex.

is_search
Additional options available: no.
Checks if search result page archive is being displayed.
See is_search description on WordPress Codex.

is_archive
Additional options available: no.
Checks if any type of archive page is being displayed. An archive is a category, tag, author or a date based page.
See is_archive description on WordPress Codex.

is_post_type_archive
Additional options available: yes.
Checks if a post type archive page is being displayed. Use options icon to define which post type should the tag check for.
See is_post_type_archive description on WordPress Codex.

is_preview
Additional options available: no.
Checks if current page/post is in preview mode (not yet published).
See is_preview description on WordPress Codex.

is_paged
Additional options available: no.
Checks if page being displayed is “paged”.
This refers to an archive or the main page being split up over several pages. It does not refer to a post or page whose content has been divided into pages using the <!–nextpage–> QuickTag.
See is_paged description on WordPress Codex.

is_attachment
Additional options available: no.
Checks if an attachment is being displayed. An attachment is an image or other file uploaded through the post editor’s upload utility. Attachments can be displayed on their own “page” or template.
See is_attachment description on WordPress Codex.

is_singular
Additional options available: no.
Checks if a singular page is being displayed. Singular page is when any of the following conditional tags return true: is_singleis_page or is_attachment.
Use options icon to define specific post types the tag should check for.
See is_singular description on WordPress Codex.

comments_open
Additional options available: no.
Checks if comments are allowed on the current post/page.
See comments_open description on WordPress Codex.

has_excerpt
Additional options available: no.
Checks if the current post has an excerpt.
See has_excerpt description on WordPress Codex.

is_user_logged_in
Additional options available: no.
Checks if the current visitor is logged in.
See is_user_logged_in description on WordPress Codex.

is_user_guest
Additional options available: no.
Checks if the current visitor is a guest (not logged in).

is_author
Additional options available: yes.
Checks if an author archive page is being displayed. Use options icon to check for a specific author’s archive.
See is_author description on WordPress Codex.

is_user_admin
Additional options available: no.
Checks if the current visitor is logged in and has administrator privileges (manage_options capability).

is_user_role
Additional options available: yes.
Checks if the current user has one of selected user roles. Custom roles are supported. Use options icon to select roles.
See current_user_can description on WordPress Codex.

Debugging

If you’re having problems writing complex conditional statements or a widget is not visible where it should be, you can easily find out what’s going on with the debug feature.

Login and configure the widget’s settings. Open the problematic page with “wn-debug” GET parameter. Ie:www.gsu.edu/?wn-debug. On the very bottom of the page you’ll see a box with debug info for every widget and every conditional statement that was run to determine its visibility. Please note that you have to be logged in to see debug info.


Feedback and Knowledge Base