How to Create Dynamic Menus in WordPress

How to Create Dynamic Menus in WordPress

Over the years, WordPress has morphed from being just a blogging platform to a super functional Content Management System or CMS. It’s growth over the past few years has been phenomenal overtaking established players like Joomla! and Drupal. A business website however has very different requirements compared to a blog. While they may incorporate one as a subsite, the main organizational landing pages need to have a navigation structure that is separate from the defaults we have in WordPress. Dynamic menus are one example where the menu items keep changing depending on what page we’re currently on. In this tutorial we take a look at how to create dynamic menus in WordPress and replicate the functionality found in a traditional corporate site.

An Example of Dynamic Menus

I’m taking an example from my own freelancing website. I have several niche areas in which I write and I require my website to display relevant content depending on the current page. For example, I want to display samples of technical writing on the relevant sub page whereas I want to provide examples of blogs I have written for in my blog category.

samples

Traditional menus in WordPress remain the same regardless of the page content. This is ideal for static links, recent posts, most popular pages etc. But what I require is a dynamic menu item list that provides relevant links while also maintaining a static structure for certain items like the “Contact Me” link.

Using the Widget Context Plugin

One way to work around this limitation of WordPress is to make use of widgets. Using the “Text” widget, you can insert and build any kind of menu or link structure. To start off with, download and install the Widget Context plug-in. This allows you to utilize the existing sidebars of your website to place your menus while at the same time allowing you the option to finely control where they will be displayed.

With this capability, you can create dynamic menus that more accurately replicate the functionality of a corporate website instead of a blog.

Go to the “Appearances” section of the dashboard and select “Widgets”. Create the menu in HTML for a given set of pages and add the text widget to one of your sidebars. With the plug-in installed, you can see a new section has been added to the bottom allowing you to specify its placement as shown below.

show on selected

From the drop-down menu, select “Show on Selected” and then take the appropriate areas where you want the widget to display. You can choose to include all pages, posts, author pages, 404 error pages etc. In case you want more fine-grained control based on the URL, you can make use of the option below that allowing you to target pages using a combination of the URL and wildcard characters. This gives you incredible flexibility in deciding exactly where you want your menu text widget to show up.

As a test, I have selected to show a text widget in the “Personal” category of my blog. To do this, I have specified the URL as /category/personal/ as shown below.

Target by URL

And sure enough when I visit a URL that matches the string, the text widget appears as promised.

personal text

Note that you can enter several locations for the widget to appear when configuring the URL and wildcards. Simply input each location in a new line.

This simple plug-in allows you to convert WordPress from a “pure” blogging platform into a full-fledged CMS solution with unparalleled flexibility and ease-of-use. With all the customization options, it’s easy to craft a website that is every bit as functional as one created using Joomla! or Drupal.

2 Comments on “How to Create Dynamic Menus in WordPress”!

Leave a Reply

This Website is Hosted by

Powered by RamNode

Disclosure: We receive a compensation from some of the companies whose products or services are presented on our website.