Welcome to Dagon Design. In addition to free scripts, WordPress plugins, and articles, we offer a variety of services including custom theme design, plugin creation, and PHP scripting. Contact me for more information.

Updated Friday, April 6th, 2007 at 4:16pm

List Subpages Plugin for WordPress

This WordPress plugin generates a list of subpages for the page being viewed. You can use this plugin by inserting the trigger text in your page (where you want the list to appear), or by calling the function directly from your template file. One key feature of this plugin is that it can used outside the loop, which means you can display a list of subpages of the current page in your header, sidebar, or anywhere else. There are also several options available. You can change the sort method, exclude pages, adjust the page depth, show the date, and more.

Download

Installation

  • Download the above file
  • Rename dd-list-subpages.txt from .txt to .php and upload it to your plugins directory
  • Activate the plugin from the WordPress admin panel
  • Configure the options under the admin panel: Options - DDListSubpages

Change Log

  • 04-06-07 Version 1.0 - First release.

Usage

To display the list of subpages on your page, just add the trigger text to your page:

<!-- ddlsp -->

(If you are using the visual editor in WordPress, you may have to temporarily disable it to add in the trigger text)

You can also call the function directly from a template file with the following command:

<?php echo ddlsp_generate(); ?>

If you use this method, it does not have to be in your loop, which means you can display the list of subpages anywhere you like in your theme.

Whichever method you use, just remember that it only generates the list when viewing an actual WordPress page which has subpages.

Options

Here are the options available for this plugin under the WordPress admin panel. The options page also includes a ‘load defaults’ button.

Before List

This text is added before the list of pages.

After List

This text is added after the list of pages.

Sort Column

You can choose to sort the list by page title, menu order, page date, page modified date, page ID, page author, or page name (slug).

Sort Order

This lets you choose between an ascending or descending sort.

Excluded Items

This is a comma-separated list of page IDs you want to exclude from the list.

Included Items

This is a comma-separated list of page IDs you want to include. If you use this feature, only pages manually specified will be listed.

Page Depth

This is the depth of subpages that will be shown. The default is 1, and 0 means no limit.

Show Date

If enabled, the date will be shown after each page.

Date Format

If showing the date, this is the PHP date format that will be used.

List Title

This is an optional header for the list of pages.

Pages: « 6 5 4 3 2 [1] Show All

  1. Wow. Such a great and easy plugin. Even works with K2.

  2. 14
    Gigi

    This plugin is wonderful and seems to work perfectly. (wordpress 2.2 for me)

    Only when i try to INCLUDE a specific subpage with its ID it does not work.
    Do you know why ?

  3. Ruzel: This plugin only lists child-pages of the current page.

  4. This is a great plugin. I’m not really sure how it’s different from wp_list_pages(), but regardless, the code is solid. If anyone came here, like me, though, looking for a way to list sibling pages, check this code:

    http://www.webspaceworks.com/resources/wordpress/30/

  5. Stephan: Thanks for the heads up - fixed ;)

  6. I just came across your neat plugin. However, I have a suggestion that has nothing to do with it. :)
    Recently I changed my browser’s default background color and font to something else than the default white and Times New Roman to see who has set it on their website and who forgot it. And you… yeah, go figure. ;) It’s interesting how many websites (and even some of the big ones) forget it and the sites look really crappy then.

    You might wanna set a body background color in your stylesheet. ;)
    Cheers!

  7. 9
    Byron

    ok thanks :)

  8. Byron: This plugin only works on pages that have sub-pages.

  9. 7
    Byron

    Hi,

    I’m come to the same roadblock as Ash.

    I have an About page that displays 6 of its child page links in the sidebar. Once I go to one of the child pages, the list in the sidebar is gone ie. it doesn’t display its sibling pages any more.

    I can see why as I’m is no longer on a page with subpages. Would there be a workaround?

    Here’s hoping and many thanks for the plugin :)

    Byron

  10. Ash: It should do that actually. Even if you are on a sub-page already.

  11. Hi,
    I am looking for a plug in that will display subpages in a heirachy. EG. “Page one” has seven subpages. Each “subpage” has “100 sub-sub pages” and each sub-sub page has “10 sub- sub-sub pages” Does this plug in order these and how does it display if so?

    CVheers
    Andy

  12. This is a really handy plugin!

    I have a question though, would it be possible to view the list of subpages if you are viewing a subpage from that list?

  13. Jordan: I will keep that in mind for all my plugins actually :)

  14. The only suggestion I have for the plugin is on the admin page, you have “load default options,” and then “update options.” Most forms will have a submit/reset (in that order) so I noticed that I will keep going to “load default options” rather than update options. Not sure if anyone else would prefer it that way, but just figured I’d mention it.

    Otherwise nice plugin =)

  15. Thank you!!!!

Pages: « 6 5 4 3 2 [1] Show All

Leave a Comment

Before you comment: If you are having an issue with a script, please make sure you have read the entire article. Also, please read through the comments because most common issues have already been discussed many times. Thanks.


Be sure to wrap all code in <code></code> tags.