Subpage Listing
About
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).
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
Usage
Blank pages will automatically be given a navigation tree. This allows you to quickly create “container” pages (all you do is fill in a title, and choose the page’s parent.)
If you would like to insert the navigational tree manually (that is, surrounded by text of your choosing), use the “Subpage Listing” quicktag that will show up on the Write Page screen. This will insert the tag: <!--%subpages%--> which will be replaced by the listing of the subpages.
Note: when inserting the tag manually, make sure that there is a blank line both above and below the tag, so as to ensure proper handling of your surrounding paragraphs by WordPress.
Update (version 0.6)
Version 0.6 is a massive update that adds a bunch of new functionality. The ability to show the current page’s parent has been added, as well as the ability to show the current page’s siblings. You can also supress the showing of children, and show only siblings, parents, or both. To use these features within a post, use this syntax: <!--%subpages(5,1,1)%--> The first “parameter” is the depth you want to show. You can set this to 0 to suppress display of children. The second “parameter” is a boolean switch for display of the parent page. The third “parameter” is a boolean switch for display of sibling pages. All are optional, although if you want to set the second “parameter”, you also have to set the first, and if you want to set the third, you have to set all three.
There is also a new function for use in your templates. Many people wanted to show subpages or siblings in their sidebar, so now you can do that. <?php txfx_wp_subpages(); ?> is the most basic form, but it can take many parameters. <?php txfx_wp_subpages(5, false, false, '<ul>', '</ul>', true); ?> will show 5 pages deep (first parameter), hide the parent (second parameter), hide the siblings (third parameter), wrap the whole thing in ‘<ul>’ and ‘</ul>’ (fourth and fifth parameters), and will echo the result (sixth parameter). These happen to be the default settings, that I have just illustrated.
Please let me know what creative uses you come up with for this plugin by leaving a comment below!
Versions
- 0.6.1 Fixed a bug regarding dollar signs being interpreted as preg backreferences
- 0.6
txfx_wp_subpages()function,<!--%subpages(5,1,1)%-->style of tag within posts, ability to show parents, siblings. Big thanks to Scott R. Godin for feature suggestions and beta testing on this release - 0.5 Internal release
- 0.4 Changed the JavaScript that inserts the quicktags. Update if you were having problems with that.
- 0.3 Initial public release/


[...] 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). [...]
Sounds good Mark, but download link is a blank file.
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.
Like this plugin, Mark. Nice work. Any trick to getting it to appear in the sidebar?
[...] 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 <!–%subpages%–> 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() [...]
[...] Subpage Listing [...]
[...] Subpage Listing [...]
. 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
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
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
Nice, I use Navigo which I think gives you more options, ovidiu I think it has support for that too.
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.
[...] 1. How like or unlike is this to Skippy’s In-Series, Mark Jaquinth’s SubPage Listing, and Owen Winkler’s list subPages? [...]
Is there an easy way to suppress the subpage listing on top-level pages? Otherwise, this is perfect so far!
Would it be possible to change the way listed subpages are sorted? E.g. I’d like to sort them alphabetically by their slug.
[...] Subpage Listing [...]
THis is a tool to show the hieararchial tree of pages and subpages in Wordpress. az< <
[...] 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. [...]
[...] Subpage Listing (tags: wordpress plugin) [...]
[...] Subpage Listing [...]
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
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
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.
[...] New resources page which centralizes bookmarklets, downloadable calendars, web feed reader plugins, glossary (under construction) and all others, thanks to Subpage Listing. [...]
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
I want to display the subpages in menu_order too!
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…
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.
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.
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.
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.
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?
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
Forget it… I did it.
The subpage already shown…
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
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!!
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.
[...] 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 [...]
[...] Visit [...]
[...] Subpage Listing [...]
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.
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.
thanks good..
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
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.
errrrrr….. didn’t working!
how to make sub pages view only at pages that we want. Not all of parent that have sub pages will display. Thanks before
[...] 7http://txfx.net/code/wordpress/subpage-listing/5 [...]
[...] Subpage Listing - Displays a directory-like listing of subpages where <!–%subpages%–> exists in the content of pages. [...]
[...] 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. [...]
i just donate some money for your coding man and than`s for sharing with us
[url=http:%2
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.
[url=http://d
[...] 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. [...]
[...] (wordpress webdesign cms templates) Bookmark [Discover] Subpage Listing [ Tempus Fugit | TxFx.net ] http://txfx.net/code/wordpress/subpage-listing/ (wordpress plugin menu navigation) Bookmark [...]
[...] Subpage Listing [...]
[...] 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 [...]
[...] 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 [...]
Thought I’d buy you a beer for your coding efforts. This helps a lot. Thanks!
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.
[...] Subpage Listing by Mark Jaquith [...]
The plugin is working fine!
Ow, what a great plugin.
[...] 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 [...]
[...] Subpage Listing [...]
Hi Mark -
Enjoyed meeting you at WordCamp Dallas this year. Curious if subpage plugin works well with 2005?
Thanks
Kevin, I’ve had no problems!
Is there an easy way to remove the sidebar feature?
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.
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
The quicktag fails to show up for me - what could be causing that please??
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
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!!
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!
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?
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)