and like us on FB

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].

■ ■ ■

  1. About Us
  2. Contact
  3. Privacy and Terms
  4. Reference
  5. Telephone Consultation
  6. Code Reference
  7. Example Pages
  8. Frequency Asked Questions
  9. Landing Pages
  10. Tools
  11. Legacy Features
  12. Charity
  13. 404 Not Found

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 with Shortcode
Description: Generate a Hierarchical Sitemap of WordPress Pages with Shortcode.
Download: Shortcode (V0.2) | WP Plugin (V0.2) | | Plugin Page

Shortt URL for this post: http://shor.tt/Asq