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.

Version 1.0   Updated Friday, February 20th, 2009 at 7:19pm

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

  If you have found this page useful, please consider donating. Thanks!

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: [9] 8 7 6 5 4 3 2 1 » Show All

  1. 129
    Anna

    Hi thanks for the plugin. I activated it in one of my sidebars. My problem is that after I click on a sub page link the sub menu disapeard and I would like it to always show in this particular sidebar even when I am on a subpage.

    That way you dont have to go back.
    thank you.

  2. 128
    tracy

    thanks…exactly what i was looking for…but i do need to modify it so that it shows a thumbnail (custom field) and a bit of an excerpt
    thanks so much

  3. can anyone tell me how can i install this plugin in wordpress…I am unable to install it. Pls. tell me step by step in brief

  4. Hello and thank you for your time and energy in putting this together! I have a question: I have a button called “Credits” and it has two child pages, “Film” and “Television.” Then, under “Film” I need a list of its subpages to show, and under “Television” I need its subpages to show as well. Currently I’m only getting “Films” and “Television” to show up under my “Credits” page. Is it able to show the “sub-sub-pages” as well as I drill down farther into my pages? Thank you!

  5. 125
    great plugin

    i am calling in my sidbar.php
    my question is it possible to dynamically change the name so that on the “about us” page i can have the title be “about us” and list sub pages, then when i display on “services” page have the title say “our services” sorry if this is basic php i am newbie
    thanks

  6. It’s excellent, but is it going to work on my new iMac??? ;-)

  7. 123
    Sean

    I wanted to pass the options for the list specifically from the function in the template so I modified the head of ddlsp_generate:

    function ddlsp_generate($options = array()) {
    if(!isset($options['before_list'])){
    $before_list = get_option(‘ddlsp_before_list’);
    }
    if(!isset($options['after_list'])){
    $after_list = get_option(‘ddlsp_after_list’);
    }
    if(!isset($options['sort_column'])){
    $sort_column = get_option(‘ddlsp_sort_column’);
    }
    if(!isset($options['sort_order'])){
    $sort_order = get_option(‘ddlsp_sort_order’);
    }
    if(!isset($options['exclude'])){
    $exclude = get_option(‘ddlsp_exclude’);
    }
    if(!isset($options['include'])){
    $include = get_option(‘ddlsp_include’);
    }
    if(!isset($options['depth'])){
    $depth = get_option(‘ddlsp_depth’);
    }
    if(!isset($options['show_date'])){
    $show_date = get_option(‘ddlsp_show_date’);
    }
    if(!isset($options['date_format'])){
    $date_format = get_option(‘ddlsp_date_format’);
    }
    if(!isset($options['title_li'])){
    $title_li = get_option(‘ddlsp_title_li’);
    }
    ///
    THere is probably a less redundant way to write this
    ///
    And now you can call it from the template with

    false)); ?>
    passing to the array any of the startup options

  8. Hey, thanks a lot for this plugin. It is exactly what I was looking for. Little input for future versions: it would be very nice, to integrate little thumbnails of pictures according to the particular subpages.

  9. This is a great little plugin, thank you!

Pages: [9] 8 7 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.