Today we learn how to create custom wordpress sidebar with widget logic.
Now a days add any custom menus in your wordpress theme become very easy task. Sidebars are very important part of the wordpress theme. Create custome wordpress sidebar can complete the theme layout , which aren’t a part of usual content, such as menus, text excerpts, and various other kinds of widgets.
You May Also Like:
- 40+ Awesome Flat WordPress Theme Designs
- WooCommerce AJAX Product Filter – WordPress Plugin
- Top Travel WordPress Themes for Hotel & Apartment Reservation
- Best Collection of WooCommerce Plugins
- 60+ Best Commercial PHP Scripts for Application
- Best Plugins to Integrate Google Font API In WordPress
- 40+ Of The Best & Top Selling Minimal WordPress Theme
The Widget Logic plugin essentially gives every widget a new field where you can specify where it should appear. You may want to have a custom sidebar on every single page on your WordPress blog, and Widget Logic is just the right tool to achieve this. 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’sConditional Tags, or any general PHP code.
INSTALL WIDGET LOGIC
The plugin is available to download on the WordPress plugins directory. You could also install the plugin from your WordPress website. There is virtually nothing to configure at all. You just install and activate and you are ready to go.
- Uploadwidget-logic.php to the /wp-content/plugins/ directory
- Activate the plugin through the ‘Plugins’ menu in WordPress
- That’s it. The configuring and options are in the usual widget admin interface.
Mostly you have 3 pages Home , About and Contact. If you want to simply appear on hompage only. you would need to visit the widget configuration page on your WordPress website and open the widget to display it’s settings. A logic field will now viewable and you will be able to enter a conditional tag to choose where to display this widget. To display this widget purely on the homepage, you write this.
if you want to appear sidebar on any other page it is important to know the ID of particular page. Once you have acquired the specific Page ID’s that you need, you will need to implement them in to the following code:
The above code means that only those three pages will be shown on that pages relative sidebar.
There are several other tags that can be used within the logic field that can be classed as somewhat advanced, such as:
This tag will make this widget only viewable to administrators only :
This widget is only viewable to those who have reached the page through a google search :
This widget will appear for posts tagged with “featured” :
For all posts in the “WordPress” category :