WordPress pages, unlike posts, are arranged in a child-parent hierarchical relationship. This relationship makes grouping content under a single umbrella a key feature of WordPress. Not totally unlike the shortcode we've previously provided that would render child pages of a parent page, this function, utilizing WordPress' wp_list_pages() function, will display a hierarchical sitemap of all pages on your website, or those that share a parent page.
We considered and quickly moved on from this function when considering how to render our platform help pages. That said, it may still come in useful.
The Result
Printing out all the pages on our site is achieved with the shortcode of [bmsitemap]
.
■ ■ ■
- About Us
- Contact
- Privacy Policy
- Terms of Use
- General Disclaimer
- BeliefMedia Home Page
- Code Reference
- Tools
- Martin Khoury
- Make an Appointment
- BeliefMedia Marketing Blog
- What We Know About You
- Unsubscribe
- Thank You For Downloading our Marketing Guide
- An Introduction to Search Engine Optimisation
- What a Real Marketing Funnel Looks Like
- The Funnel Subscription Conditional Redirects
- Your Website is a Vital Marketing Asset
- Australian RBA Graph and Inflation
WordPress Shortcode
Copy and paste the WordPress function into your theme's functions.php
file or, if you sensibly have one installed, your custom functions plugin. You may optionally download and install our plugin from the bottom of of the page.
If you require shortcode to work in a sidebar widget, you'll have to enable the functionality with a filter. If you're using our custom functions plugin, you'll have that feature enabled by default.
An alternate method of printing the map (and that which is documented) would be passing the arguments in an array (the function uses wp_parse_args()
to merge the $args
with the $defaults
values). In fact, we could do away with the virtually every statement after the $atts
array, and pass the $atts
array directly to the wp_list_pages()
function.
Most of the shortcode attributes are detailed on the WordPress Codex page . Those that aren't are parent
(the parent page of the list) and list_style
. The list styles are detailed on W3schools (and WP ).
Considerations
- If you want to create a custom list, consider create a custom walker class to extend
wp_list_pages()
(inheriting the properties of the Walker_Page class). Usage of an extended class essentially means you can modify the list in virtually any way.
Download
Title: Sitemap of WordPress Pages (WP Plugin)
Description: Generate a Hierarchical Sitemap of WordPress Pages with Shortcode.
Download • Version 0.2, 1.9K, zip, Category: WordPress Plugins (General)
WordPress Shortcodes, (1.1K)