Subpage Listing

Subpage Listing allows you to take full advantage of WordPress Pages’ hierarchy by generating a navigational tree of the pages below them (subpages).

For example, say you have a parent page called “Parent.” Now, say you have 3 pages under “Parent,” called “Child1,” “Child2,” and “Child3.” Now, say that you have 2 pages under “Child2″ called “Grandchild1″ and “Grandchild2.”

Subpage Listing would create a navigation tree for “Parent” that looks like this:

  • Child1
  • Child2
    • Grandchild1
    • Grandchild2
  • Child3

This allows you to very easily create a complex hierarchical structure that can be browsed.

Download

Latest version: Download Subpage Listing v0.6.1 [zip]

This plugin has been downloaded 10390 times.

Installation

  1. Upload plugin-name.php to the /wp-content/plugins/ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
  3. Place <!--%subpages%--> in an page’s content and it will be replaced with a hierarchical list of subpages
  4. See “Advanced Usage” for more detail

Donate

I’ve spent a lot of time writing this code and supporting it. If you derive some benefit from this code, please consider showing your gratitute in a more tangible
way. Thanks!

I have received $10.50 this month for my coding efforts.

Donate with PayPalAmazon.com Wishlist


91 Responses to “Subpage Listing”

  1. . Change that (using SQL) to ‘draft’, and now they’re draft posts, not pages. I used the following plug-ins: Static Front Page – Sticks the page with a slug of ‘home’ to your front page. Subpage Listing

  2. [...] Subpage Listing is a WordPress plugin that allows people to take full advantage of WordPress Pages’ hierarchy by generating a navigational tree of the pages below them (subpages). [...]

  3. FilSchiesty (subscribed) says:

    Sounds good Mark, but download link is a blank file.

  4. Mark says:

    Grr… thanks. That’s what I get for relying on an external service to package the zips for me. I just did it manually for now. Gotta write some code to do SVN checkouts and generate zip files automatically.

    Link should work now.

  5. Darrell Schulte (subscribed) says:

    Like this plugin, Mark. Nice work. Any trick to getting it to appear in the sidebar?

  6. [...] Code cleansing. Adds quicktag button. <?php /* Plugin Name: Subpage Listing Plugin URI: http://txfx.net/code/wordpress/subpage-listing/ Description: Displays a directory-like listing of subpages where &lt;!–%subpages%–&gt; exists in the content of pages.  Also, it will be displayed if a page is blank. Author: Mark Jaquith Version: 0.3 Author URI: http://txfx.net */ /*  Copyright 2005  Mark Jaquith (email: mark.gpl@txfx.net)     This program is free software; you can redistribute it and/or modify     it under the terms of the GNU General Public License as published by     the Free Software Foundation; either version 2 of the License, or     (at your option) any later version.     This program is distributed in the hope that it will be useful,     but WITHOUT ANY WARRANTY; without even the implied warranty of     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     GNU General Public License for more details.     You should have received a copy of the GNU General Public License     along with this program; if not, write to the Free Software     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */ /* Many thanks to Owen Winker for his Edit Button Framework [ http://www.asymptomatic.net/wp-hacks ] */ function txfx_wp_subpage_display($text) { /* — SETTINGS ———————————– */ $depth = 5; // how many levels down do you want to go? /* ———————————————— */ if ( !is_page() ) return $text; global $post; if ( strpos($text, ’<!–%subpages%–>’) !== FALSE || empty($post->post_content) || $post->post_content == ”<br />n” ) {         $subpage_text = wp_list_pages(‘child_of=’ . $post->ID . ’&depth=’ . $depth . ’&echo=0&title_li=0′);         if ( strpos($subpage_text, ’</li>’) === FALSE )                 return str_replace(‘<!–%subpages%–>’, ”, $text);         if ( strpos($text, ’<!–%subpages%–>’) !== FALSE ) {                 return str_replace(‘<!–%subpages%–>’, ”<ul>n $subpage_text n </ul>”, $text);         } else {                 return ”<ul>n $subpage_text n </ul>”;         } } return $text; } function txfx_wp_subpage_display_js() {         global $post_status;         if( strpos($_SERVER['REQUEST_URI'], ’page-new.php’) ||  (strpos($_SERVER['REQUEST_URI'], ’post.php’) && ($post_status == ’static’)) ) : ?>         <script language=”JavaScript” type=”text/javascript”><!–                 var toolbar = document.getElementById(“ed_toolbar”);         <?php         edit_insert_button(“Subpage List”, ”txfx_subpage_list_display”, ”Subpage List”);         ?>         function txfx_subpage_list_display() {                 edInsertContent(edCanvas, ’nn<!–%subpages%–>nn’);          }         //–></script>         <?php endif; } if(!function_exists(‘edit_insert_button’)) {         //edit_insert_button: Inserts a button into the editor         function edit_insert_button($caption, $js_onclick, $title = ”)         {         ?>         if(toolbar)         {                 var theButton = document.createElement(‘input’);                 theButton.type = ’button’;                 theButton.value = ’<?php echo $caption; ?>’;                 theButton.onclick = <?php echo $js_onclick; ?>;                 theButton.className = ’ed_button’;                 theButton.title = ”<?php echo $title; ?>”;                 theButton.id = ”<?php echo ”ed_{$caption}”; ?>”;                 toolbar.appendChild(theButton);         }         <?php         } } // For the quicktag button add_filter(‘admin_footer’, ’txfx_wp_subpage_display_js’); // doing it this way for compatibility with the Preformatted plugin add_filter(‘init’, create_function(‘$a’, ’add_filter(‘the_content’, ’txfx_wp_subpage_display’, 9);’)); ?> Note: See TracBrowser for help on using the browser. searchHighlight() [...]

  7. sami (subscribed) says:

    Thanks Mark, it helps me to arrange childs (chapters) of my e-book. I’m working on : http://www.fikra.kitab.nl/?page_id=15

  8. ovidiu says:

    hi there,

    is there a way to influence the order of appearance in a subpage listing?

    to me it appears as if the subpages are ordered alphabetically, isn’t it?

    cheers
    ovidiu

  9. Usayd says:

    Nice, I use Navigo which I think gives you more options, ovidiu I think it has support for that too.

  10. line 51 of the script, the final <ul> should be <ul class=”children”> in order to properly control via css the resultant sub-pages for display. Discovered I’d ‘fixed’ this when I upgraded to 0.6.1 from the original. Thought you might want to know. :-)

  11. [...] 1. How like or unlike is this to Skippy’s In-Series, Mark Jaquinth’s SubPage Listing, and Owen Winkler’s list subPages? [...]

  12. Justin Moore says:

    Is there an easy way to suppress the subpage listing on top-level pages? Otherwise, this is perfect so far!

  13. Iva (subscribed) says:

    Would it be possible to change the way listed subpages are sorted? E.g. I’d like to sort them alphabetically by their slug.

  14. Knuts blogg says:

    THis is a tool to show the hieararchial tree of pages and subpages in Wordpress. az< <

  15. [...] To showcase subPages on WordPress Pages, you can manually type in the links to the subPages, or take advantage of the Subpage Listing WordPress Plugin by Mark Jaquith. [...]

  16. Cris Bloomfield (subscribed) says:

    PSA: Anyone looking for Chris McCaffrey’s Wordpress list_peer_pages.php script recently won’t have been able to find it as it appears his website is offline.

    I think that the solution people looking to use this plugin provides has been solved elsewhere. Consider this example:

    If the page structure for the website is as follows

    Page A
    - Child A Page A
    – Grandchild A Page A
    – Grandchild A Page B
    - Child A Page B
    - Child A Page C
    Page B
    Page C

    When in one of the grandchild pages I want to be able to see all the grandchild pages.

    Now I need the menu to be dynamic, so I can’t just statically address the pages. In my mind I would describe this as wanting the navigation menu to show the peer pages to the current page aka the brothers/sisters aka the siblings.

    i.e. the navigation menu will show

    – Grandchild A Page A
    – Grandchild A Page B

    when you are looking at either Grandchild A Page A or Grandchild A Page B.

    The means to do this has been provided by Kafkaesqui over at http://wordpress.org/support/topic/89781. Basically used this code:

    post->post_parent) ) {
    $parent = $wp_query->post->ID;
    } else {
    $parent = $wp_query->post->post_parent;
    }

    wp_list_pages(“title_li=&child_of=$parent”);

    } ?>

    Hope that helps some one else!

    Cris

  17. Cris Bloomfield (subscribed) says:

    Er…

    it didn’t like that PHP code did it ;)

    Here’s a link to the plugin.

    http://media.stars.manchester.ac.uk/webdev/wp-plugins/list_peer_pages.zip

  18. Chris (subscribed) says:

    Is it possible to use this plugin and then list the pages in menu order? I can’t seem to escape pages being listed alphabetically with this.

    Thanks.

  19. [...] New resources page which centralizes bookmarklets, downloadable calendars, web feed reader plugins, glossary (under construction) and all others, thanks to Subpage Listing. [...]

  20. Related Entries, yet another powerful WordPress plugin. New resources page which centralizes bookmarklets, downloadable calendars, web feed reader plugins, glossary (under construction) and all others, thanks to Subpage Listing. Thanks to all the people who left comments, I read them all and appreciate them. Hope you all enjoy the new look. You can expect even better content to come. There are some minor issues in my to-do list which I expect to to iron in the next few

  21. yoyo (subscribed) says:

    I want to display the subpages in menu_order too!

  22. Plugin WordPress: Subpage Listing…

    Anche oggi un plugin per lavorare con pagine e sotto-pagine di WordPress.
    Questo in particolare vi fornisce un tag da inserire (per esempio) nella sidebar del vostro blog per elencare tutte le sotto-pagine di quella mostrata, traendo così il massimo v…

  23. Jennifer says:

    For everyone asking whether the ordering of subpages can be changed, the answer is yes- if you are willing to change a bit of code in the plugin.

    To list your Pages in the order defined by the Page Order setting in the Administration > Write > Write Page panel, you have to modify the code in the plugin:

    1. From your Wordpress admin page, click on “Plugins”.
    2. Next to the “Subpage Listing” plugin, click on “edit”.
    3. Find this code:


    if ( $show_siblings ) {

    $siblings = wp_list_pages('child_of=' . $post->post_parent . '&depth=1&echo=0&title_li=0');

    4. Did you find it? Good. Now replace this:

    '&depth=1&echo=0&title_li=0'

    With this:

    '&depth=1&echo=0&title_li=0&sort_column=menu_order'

    And that should do it.

  24. deKay says:

    I’ve installed this plugin today (WP 2.1.2) and am using a slightly modified The Porters theme (just colour and graphic changes, no layout). Unfortunately, the “txfx_wp_subpages()” bit (in the sidebar in php tags, obviously) does nothing. At all.

    Where can I start looking at what is wrong? I’m using v0.6.1 of the plugin.

  25. Dennis says:

    The first thing I wanted to make it do was make it sortable by page order rather than alphabetically. While it was pretty easy to edit the wp_list_pages line to fix it, it’d be nice to have it configurable.

    I was halfway to hacking in another flag to make it sort by page order on demand when I realized it would be easier to just add the entire sort order field as a parameter, allowing any type of sorting by the user.

    So there it is.

    I’m also looking for a function to not just list child pages of a page, but to actually insert them. So if you have a blank page, you add the tag and they get included.

    The utility of this is to build a technical document in sections and have the sections expand and collapse within the higher level page.

    But I’ll probably just write that stuff.

  26. Lorin Rivers says:

    I couldn’t get this to work either. I put the tag into the content area of my page template and it just acts like a comment.

  27. Marc says:

    I’ve put in the wp_list_pages vars to sort by menu_order but my menu still comes up in alpha order instead of menu_order. I’ve changed each of the page order numbers to be consecutive but the list order doesn’t change. Any help?

  28. It doesn’t works on my site. Would you please fix the bugs for this plugins. I still receive many errors on my site when implementing this plugins.

    Regards
    http://www.angellica2017.com

  29. Forget it… I did it.
    The subpage already shown… :)

  30. Steven Vu (subscribed) says:

    I love your plugin although it misses a vital function.

    Page A
    - Child A Page A
    – Grandchild A Page A
    – Grandchild A Page B
    – Grandchild A Page C
    – Grandchild A Page D
    – Grandchild A Page E
    – Grandchild A Page F
    - Child A Page B
    - Child A Page C
    Page B
    Page C

    When viewing Grandchild A Page A you can view it’s siblings and the parent but you can’t view the page you’re on. While it might not seem logical at first to be able to view the page you’re on, when in use the menu jumps.

    When on page C

    – Grandchild A Page A
    – Grandchild A Page B
    – Grandchild A Page D
    – Grandchild A Page E
    – Grandchild A Page F

    When on page E

    – Grandchild A Page A
    – Grandchild A Page B
    – Grandchild A Page C
    – Grandchild A Page D
    – Grandchild A Page F

    It’s very easy to lose track of what page you’re viewing. An example is here: http://testteachtuition.com/11_plus/free-practice-papers/city-of-london-school-for-boys/

    I can offer recompense of 10 sterling pounds if you’re willing to do it within a week.

    Regards,
    Steven Vu

  31. NBoy says:

    WP 2.2 runs fine with this, I have used the following in my template

    ‘, ‘‘, true); ?>

    I also have the same issue, the plugin works 99.99% exactly as I need, apart from the fact that it hides the current sibling in the sibling view just as Angellica said above.

    I’m gonna have a look at the code, but I’m no real PHP coder! I presume you have coded the function to hide the current sibling, so it basically functions as ‘when viewing sibling, display all siblings of parent EXCLUDING current page’.

    If you (or anyone else) has any suggestions on how to fix this, it seems we would both be very greatfull!!

  32. NBoy says:

    Whoops, my code didnt come out right at all, please ignore it! I have not solved the issue yet, man I wish I could get it to always show all siblings and not exclude the one currently being viewed.

  33. [...] be that only the Photos pages would appear in Photos) I’ve had to find another plugin called Subpage Listing that puts a simple comment in the page posts to provide a list of the subpages per page. It [...]

  34. youtube says:

    Great plugin, only one issue for me: Using WP 2.0.5, on the search results page it says “Search Results for:(blank)” where (blank) should be the terms searched for.

  35. indir says:

    I’m a real newbie with WordPress, as i am with most of the internet, but I’m going to give this a go. I’ll let you know how I get on with it.

  36. Steven Vu (subscribed) says:

    I’m using your plugin to order 250 pages or so. I couldn’t get the current page to view inside your list so only showed your list a level above. That coupled with a breadcrumb plugin I found means it’s quite usable.

    The real problem i’m having at the moment is getting the pages to list using the page_order that you set. The fix you mentioned above doesn’t work i’m afraid.

    Sure you can’t fix this? i’ll give your 10$ and all the love in the world.

    Steven

  37. Steven Vu (subscribed) says:

    I think I’ve managed to get page_order to work. Change this:

    if ( $depth > 0 )
    $subpage_text = wp_list_pages(‘child_of=’ . $post->ID . ‘&depth=’ . $depth . ‘&echo=0&title_li=0′);

    to
    if ( $depth > 0 )
    $subpage_text = wp_list_pages(‘child_of=’ . $post->ID . ‘&depth=’ . $depth . ‘&echo=0&title_li=0&sort_column=menu_order’);

    Seems to work fine. Thanks for the wonderful plugin.

  38. wawan says:

    how to make sub pages view only at pages that we want. Not all of parent that have sub pages will display. Thanks before

  39. [...] Subpage Listing – Displays a directory-like listing of subpages where <!–%subpages%–> exists in the content of pages. [...]

  40. [...]   Subpage Listing 0.6.1» Mark Jaquith (url)Displays a directory-like listing of subpages where <!–%subpages%–> exists in the content of pages. It will be displayed if a page is blank. txfx_wp_subpages() can be used to display subpages in the sidebar. See this plugin’s site for details. [...]

  41. Nikola says:

    i just donate some money for your coding man and than`s for sharing with us

  42. Odilon (subscribed) says:

    Hi, how could I customize the css by adding a class parameter to the UL or LI’s?
    The code being now generated has a different LI class for each element, being generated by each and every page ID, and so that’s impossible to match a css onto them.
    Any help appreciated to help me force the generated code to use only one ul or li class for all pages.
    TIA,
    O.

  43. [...]   Subpage Listing 0.6.1» Mark Jaquith (url)Displays a directory-like listing of subpages where <!–%subpages%–> exists in the content of pages. It will be displayed if a page is blank. txfx_wp_subpages() can be used to display subpages in the sidebar. See this plugin’s site for details. [...]

  44. [...] WordPress Pages’ hierarchy by generating a navigational tree of the pages below them (subpages). http://txfx.net/code/wordpress/subpage-listing/ In the page_feature.php temlate, I replaced this [...]

  45. [...] Pages’ hierarchy by generating a navigational tree of the pages below them (subpages).http://txfx.net/code/wordpress/subpage-listing/ In the page_feature.php temlate, I replaced this code: Code:  <h3>Recent [...]

  46. Alex says:

    Thought I’d buy you a beer for your coding efforts. This helps a lot. Thanks!

  47. eric (subscribed) says:

    hi Mark,
    I’ve just installed your plugin (WP 2.3.3) and it works fine.
    I ve looked for this solution since months.
    Many thanks.

  48. azlio says:

    The plugin is working fine!

  49. [...] list the policies, legal information, copyright, and other subPages from my About Us Page. I found txfx Subpage Listing, but you can also try List SubPages WordPress Plugin, to make the job easier to list all these [...]

  50. Kevin Dykes (subscribed) says:

    Hi Mark –

    Enjoyed meeting you at WordCamp Dallas this year. Curious if subpage plugin works well with 2005?

    Thanks

  51. Mark says:

    Kevin, I’ve had no problems!

  52. Karen says:

    Is there an easy way to remove the sidebar feature?

  53. WereBear says:

    This is one peachy plugin! Just what I was looking for.

    I gave a little donation. Wish it could be more!

    But my e-Empire is still ongoing… won’t forget you.

  54. James (subscribed) says:

    Is there a way to display the subpages on the horizontal navigation, when you click on a child of a page. I dont want the subpages listed on the page itself, only on the nav bar.

    ie: http://www.worldspotprices.com

  55. Bill (subscribed) says:

    The quicktag fails to show up for me – what could be causing that please??

  56. Bill (subscribed) says:

    I should have mentioned that the blank parent method works, shows subpage links no problem, so it can’t be an install problem.
    There is, however, nothing like what is described above:
    ‘… use the “Subpage Listing” quicktag that will show up on the Write Page screen.’.

    Can somebody please let me know what might be preventing this from working? Thanks

  57. venice (subscribed) says:

    Hello,

    This is a nice plug in. I want to make a CMS site using WP. How can this plugin be manipulated so that only the GRANDCHILD on one sidebar and not the child as I have already the CHILD appearing in the other sidebar with the PARENT page?

    Can it be done?

    Hoping for your feedback. Thanks!!

  58. venice (subscribed) says:

    Hi,

    I posted a comment yesterday. wondering why it is not here. so i would like to repeat my question, is there a way to put only the grandchild or sub-sub pages on the sidebar, meaning only the grandchild pages will appear when the sub-page is clicked. The reason I prefer only the grandchild page link to appear since the sub-page already shows on the other sidebar with the parent page.

    Your feedback is much appreciated.

    Thank you!

  59. Chris (subscribed) says:

    Trying to use this plugin with WP 2.6.3 … Works great except for one thing — it won’t display the parent link in the list. I’ve been messing around with it for most of the day and it’s really driving me nuts. It’s almost like the get_post function isn’t working anymore… anyone have any ideas?

  60. Kyle (subscribed) says:

    couple questions, please help if you’re able:

    1.) I would like to display subpages always
    (even if pages isn’t blank)
    page content would display below links

    2.) I would like to display subpages on the subpage itself

    Subpage1 title
    – subpage1 link
    – subpage2 link

    please help, thank you
    (#1 most important)

  61. aleksey says:

    Thank you.

    It would be great, I think, if this plugin could use some more function described here:

    http://codex.wordpress.org/wp_list_pages
    http://codex.wordpress.org/Function_Reference/get_pages

    Especially if could show the tree of special pages, described by ID.

  62. Tom (subscribed) says:

    No quicktag for me either (WP 2.7)

  63. scarlin says:

    I mistakenly put the line <?php txfx_wp_subpages(5, false, false, ‘

      ‘, ‘

    ‘, true); ?> in a text widget. Now widgets aren’t displayed in my sidebars. Any thoughts?

  64. TN says:

    Hello,

    Would it be possible to change the format:

    To something like:
    [subpages(5,1,1)]

    The problem is that my wordpress converts the current format to something like:
    <!–subpages(5,1,1)–>

    This means the matching does not work.

  65. TN says:

    Hah! Let’s try that again…

    Would it be possible to change the format:
    <!–%subpages(5,1,1)%–>

    To something like:
    [subpages(5,1,1)]

    The problem is that my wordpress converts the current format to something like:
    &lt;!–%subpages(5,1,1)%–&gt;

    This means the matching does not work. As you can see, there are tons of problem with < > syntax.

    (And your comments seems to be currently open to cross-site scripting attack…)

  66. TN says:

    And it would be absolutely wonderful, if this plugin would work with Language Switcher plugin…

    http://www.poplarware.com/languageplugin.html

    Alas, no win today for me…

  67. 0p0 says:

    Is there a way to display text right before the pages listing to let people know why is the list appearing without having to write a whole script?
    thanks!

  68. 0p0 says:

    nevermind I just found the way to do so, by adding “this page has childre pages” right befor the ‘ul’ tag in the parameters, cool!

  69. Paul Parenko says:

    This is how to get the whole children list, please add this as an example!

    post_parent){
    // will display the children of this top site
    $children = wp_list_pages(“title_li=&child_of=”.$post->ID.”&echo=0″);
    }else{
    // diplays only the children of
    //$children = wp_list_pages(“title_li=&child_of=”.$post->post_parent.”&echo=0″);

    if($post->ancestors)
    {
    // now you can get the the top ID of this site
    // wp is putting the ids DESC, thats why the top ID is the last one
    $ancestors = end($post->ancestors);
    $children = wp_list_pages(“title_li=&child_of=”.$ancestors.”&echo=0″);
    // you will always get the whole child list
    }
    }

    if ($children) { ?>

  70. Samoan-Ninja says:

    I really like this simple plugin..

    Maybe in the future you can have the number of times the pages have been viewed, or maybe a date-stamp when that page was created (i.e. pages = articles)..

    But overall I like it, its better than me copying and pasting id numbers, now i can just keep making pages and it’ll automatically make the list for me, again thanks!

  71. Iwan says:

    Hey there Mark,

    Nice work!

    I would really like it if it would be possible to list the subpages in a double list. Now it’s one long list which falls of the page untill you scroll down. I’d prefer it if in some way you could cut it in half and put the 2 halves next to eachother to fill the page better and skips the need to scroll down.

  72. david (subscribed) says:

    hi everybody!
    this plugin looks very nive.i would like to add subpages and sub-subpages but i have as problem…when i click on a page wich got 2subpages.my goal is that appear the 2 subpages on the parent s page.ok it is done but i don t find the way that every subpage appearing on the parent page get his own title.in fact it appear the title of the parent s page…i hope i make myself clear enough..english is not my mother tongue.if you might advice me i would really appreciate.i am lost right now.thanks a lot,
    David

  73. Araba (subscribed) says:

    Nice i got it worked , but have a question can i add this to the sidebar?

  74. Dario (subscribed) says:

    Hello.
    How can I display the subpage listing in 2 or more columns?
    Thanks

  75. tavla indir says:

    The quicktag fails to show up for me – what could be causing that please??

Leave a Reply

Note: If you are replying to another commenter, click the "Reply to {NAME} →" button under their comment to help the conversation have a better flow!

Anti-Spam Quiz: