Widget Logic

Control Widget Placement with Widget Logic

One of the easiest ways to control which WordPress Widgets display on a particular place, there is a great WordPress Plugin called Widget Logic. There used to be a more non-technical tool called Widget Logic Visual,  but of WordPress v3.5 the visual version no longer works.

Step 1: Go to Appearance > Widgets

Step 2: Add your new widget or open the widget you’d like to add logic to. Once the widget is opened look to the section at the bottom of the widget just above the SAVE button.

Widget Logic

Step 3: Adding Logic

Inside that widget logic space we can put some commands to set where this widget displays. The above example is using is_page() command… this is telling this widget to only display on pages, not single posts, categories etc, just pages.

Examples

Here is a short list of the commands that can be added to the widget logic box.

  • 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_page(array(7,12,18,24)) —  page of one of the given page IDs

In the last 2 bullets you’ll notice a bunch of numbers separated by commas. Those are  ID #’s. If you only wanted a widget to display on a set of particular pages or categories you use the appropriate command and list the ID’s of the pages.  Now you are probably asking yourself how to find the ID, check out the following  tutorial which explains just how to  Find a Page or Post ID in WordPress.

For a more command examples visit the Widget Logic page.

Leave a Reply

Your email address will not be published. Required fields are marked *