web hosting
build a website

Adding Widgets to specific pages in WordPress

Feb 9, 2014   //   by Anthony Devine   //   Website Development tips  //  No Comments

Widgets in WordPress are brilliant but the main problem they have are that they appear on every page of your site. If you want a widget to appear on just 1 page or a couple of pages without having to hardcode the widget in your core code then you need to use Widget Logic.

Widget Logic is simple to install and once installed you just move a widget to your desired sidebar and you will now notice the widget logic option on your widget. If you want the widget to just appear on a page http://www.yourdomain/windows or http://www.yourdomain/security then use the code:

is_page('windows') || is_page('security')
If you want the widget to appear on every page appart from http://www.yourdomain/windows then use the code:
!is_page('windows')