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:


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.

Download

widget logic

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.

  1. Uploadwidget-logic.php to the /wp-content/plugins/ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
  3. 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.

is_home()

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:

is_page('1,3,5')

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 :

current_user_can('level_10')

This widget is only viewable to those who have reached the page through a google search :

strpos($_SERVER['HTTP_REFERER'], "google.com")!=false

This widget will appear for posts tagged with “featured” :

has_tag (‘featured’)

For all posts in the “WordPress” category :

is_category(‘wordpress’)

widget logic

Download

About The Author

Related Posts

Leave a Reply

Your email address will not be published.