How to Control Widget Displays with Widget Logic

Posted OnDec 12, 2014     CategoryPlugins, Widgets     CommentsNo comment

Hello and welcome to the guide to the Widget Logic WordPress plugin, which is a superb plugin that is used to control the pages on which pages widgets appear on your website, using WordPress conditional tags. It also adds a widget_content filter, which allows you to modify the text displayed by any widget from your WordPress theme’s functions.php file.

Step 1) On your Dashboard, scroll down to ‘Plugins’ from the left-hand sidebar

1

Step 2) From the ‘Installed Plugin’ page, click on ‘Add New’ at the top of the page. Alternatively, click on ‘Add New’ from the dropdown menu under ‘Plugins’

2

Step 3) You will find yourself on the ‘Add Plugins’ page next. From here, use the search box in the top right-hand corner to search for your plugin

3

Step 4) From the ‘Search Results’ page, find your desired plugin and click the ‘Install Now’ button. Read the details under the blue link marked ‘More Details’ if you are unsure of anything.

4

Step 5) The plugin will unpack and install on your website. The next step is to hit the blue link marked ‘Activate Plugin’. This will complete the process.

5

Step 6) You will now be redirected to the ‘Installed Plugins’ page. From here, scroll down and check that your plugin is activated and ready to go.

6

Step 7) Head to the ‘Widgets’ page, which is found under ‘Appearance’ on the left-hand sidebar of your Dashboard. Scroll down to the bottom of your widget page to find your options for Widget Logic.  Start by ticking the boxes for ‘Add ‘Widget_Context’ filter’ (which will allow you to edit the text and appearance of your widgets in your functions.php file, giving you more flexibility with the look of your widgets on each page) and ‘Use ‘wp_reset_query’ fix’ (which is used when you are having issues with the plugin working correctly). Untick these boxes unless you feel like your widgets are going to have trouble working without that added support.

7

Step 8) The next step is to add Widget Logic to your available widgets. Choose a widget and scroll it across to the sidebar of your choice. A list of options will become available to you (including Name) and you will find Widget Logic at the bottom. Here, you can add conditions for when a widget should appear based on PHP and WordPress conditional tags. Take a read through these if you are not an experienced coder. We have added a list of them for Step 9.

8

Step 9) Here are some examples of conditional tags using PHP code. They should give you an idea of what to place in the box marked ‘Widget Logic’ at the bottom of each widget.

9

Step 10) As an example, we have added the is_home() conditional tag to our Archives widget. This means that the Archives page of the site will now only be available on the Home Page. See Step 11 for the example.

10

Step 11) When the widget is saved, and you head back to your website, your is_home() conditional tag should ensure that the Archives widget only shows on the main home page. See the images below for the Home Page (with Archives on the sidebar) and a random post (where Archives does not show because of the Widget Logic conditional tag being used.)

11a

 

11b

Leave a Reply

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

Send this to friend