We Are Microsoft Experts and Software Automation Gurus
Call us: (519) 819-4337

Archive for the ‘Web Development’ Category

WordPress: Instant Parent Navigation

WordPress: Instant Parent Navigation

WordPress: Instant Parent Navigation

I know there are a lot of new WordPress developers out there trying to figure out the core framework. From time to time, we’ll post a few tips here and there so that you can gain some insight into what we do. Here’s a trick that you may have not come across yet. If you want to load the navigation dynamically in WordPress (meaning ever additional pages added in the backend will also show up on the frontend menu) , here’s the code that can make it happen.

<?php wp_list_pages(); ?>

This code above will call in the navigation dynamically as is.  However if you do decide that you only want to show the parent navigation, you can simply add a parameter to the function.

<?php wp_list_pages(‘depth=1’); ?>

What we are instructing WordPress to do is to create a list of pages that we have in the backend, then only show the top level navigation. If you change that 1 to a 2, WordPress will output the top level and second level navigation, ignoring anything outside of that.  If you want to see the full definition of the function, you can check it out here:


Latest Posts


2268 Northway Ave., Windsor, Ontario
Phone: (519) 819-4337
Fax: (888) 868-9130
Website: http://SpiceTech.ca
Email: support@spicetech.ca