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

  1. 45
    misty

    I have a page which has a couple of linked other pages on it. Currently, I have manually put in the dates for the linked pages. I am searching for a plugin that can show the dates and author just like what the following forum page does.

    http://www.weberforums.com/forum4.html&sid=f7db7635c083e86b48b7c5ede846ad3b

    Would this plugin work for my case?

    Thanks.

  2. Sorry ammendment, only replace $thePostID = $wp_query->post->ID;

    You still need the $wp_query bit.

  3. Good point :)

    You need to replace this code inside the ddspl_generate function:

    
    global $wp_query;
    $thePostID = $wp_query->post->ID;
    

  4. Hey Luke, where do we add the code you posted? Thanks a bunch!

  5. Just found a solution to a problem that some people have mentioned.

    
    if($wp_query->post->post_parent > 0)
    		{
    			$thePostID = $wp_query->post->post_parent;
    		}
    		else
    		{
    			$thePostID = $wp_query->post->ID;
    		}
    

    What this does is says if there is a post parent (page parent in this case, silly wordpress terminology), use the id of this parent to list the subpages from. Otherwise, if there is no parent page, use the current page id. Hope that helps.

    Very nice plugin by the way :)

  6. To asshat #39….the reason is obvious. Why the hell would you want to see the sub-navigation of a section you’re not even looking at? These aren’t drop-down menus.

    To the author….thanks for a sweet plug-in!

  7. 39
    alias

    I got to say, I like this plugin but the way its designed to only list subpages on pages with subpages is the most stupid thing i ever heard

    who would make a plugin to list only subpages on a page with subpages and not the rest of of the subpage list ? this plugin is really unusable as is, but i hope the creater will fix it and make it work the way it should.

    back to searching for a functional plugin

  8. 38
    alias

    how come when you click on a subpage listed the rest of the list disappears ? This would render the plugin rather useless no ?

  9. 37
    alias

    damn i know why its not working because i don’t have any sub pages doh!!

  10. 36
    alias

    the plugin itself isn’t working i get a blank list, using wp 2.3

  11. 35
    alias

    sorting isn’t working,

  12. How do I stop the plugin from saying “This page has the following subpages…” at the bottom of my subpages? I didn’t put the call in there and can’t find it in the plugin…

  13. Hello, very good plugin but I have a question : I hava a plugin ( Page Category Plus) with which I can assign pages to categories.

    Rather than listing subpages of a page, I would like to list pages & subpages inside a category.

    How can I modify the query to make this ?

    Thanks a lot !

  14. Hi! Works fine for me but with one problem:
    When i’m on a subpage and there are no more subpages the navigation is lost.

    Maybe there is a possibility to show the subpages of a page also on the subpage?

    Regards
    Mario

  15. Great plugin! Is there a way to place your plugin on a widget?

Pages: « 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.