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. Great plugin…how would it work with categories?

  2. 83
    Zainab

    It would be cool to list descriptions of the subpage after each link.
    And better yet, list subpages of subpages. I’ve been looking for a plugin like that.

    For example:

    WRITING
    Welcome to my page about writing.

    SHORT STORIES
    Short Story 1 - This is about blah blah blah.
    Short Story 2 - Blah blah blah.

    POEMS
    Poem 1 - Blah blah blah

    It would be nice if you could make this. I’m sure many people (ahem, me) would benefit from it.

  3. 82
    Jaap

    I just can’t get it to work… I’m using WP 2.6 can that might be the problem?

  4. 81
    Demoniz

    Im using it for wordpress 2.6.2 but it seems nothing happens with the depth, im trying to change the number from the page depth from admin area but it always show all subpage list , it cannot change can you help me ?

  5. Now all we need is a way to extract subpage excerpts!

  6. hi
    now what i want is to show links list of that page’s child pages on that page.
    is it possible?

  7. 78
    Diego

    I’ve got a question:

    I’m using the <?php echo ddlsp_generate(); ?> bit inside a column on the theme…

    ..but it seems to show on every page, exept for at the very beggining (the “home” or the index.html page)

    Any suggestions to make it appear also on the very home page??

    I will be forever grateful to anyone who can assist me with this!

    Many thanks.

  8. I have found a simple solution for those who wish to put the list even when we are on a subpage.

    After the ddlsp code, just add the wp list pages code with depth of 2 to show the 1st level page and 2nd level page directory.

    
    <?php echo ddlsp_generate(); ?>
    <?php wp_list_pages("title_li=&child_of=$parent&depth=2" ); ?>
    

    An example of which I created for my website below :-

    http://www.mynetbizz.com/travelweb

  9. 76
    Reino

    I’ve a question, is there an option that the plugin will show the active page. Right now when you have 2 subpages under a page like “about”, you click a subpage and the menu will dissapear? Or am i wrong?

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.