Dynamic Subpages

This plugin creates a widget menu of the pages related to the current page. You define where in the page hierarchy to be the root of the menu, and you define the depth. Now you have a simple and dynamic navigation menu. The benefits with this plugin compared with a predefined menu is that this menu can change from one page to an other.


  1. Download the plugin at WordPress.org
  2. Upload the plugin source to the `/wp-content/plugins/` directory
  3. Activate the plugin through the ‘Plugins’ menu in WordPress


Now you can use the widget in the ‘Widget’ menu.


”start level” must be greater or equals to 1. It is a subpage plugin, not a menu plugin.


Is it working?


The current page is Subpage2. Therefore is its child pages are visible. Subpage1 has also child pages but they are only visible when the current page is Subpage1 (or any child of Subpage1).


  • English
  • Italian by NeoMod
  • Swedish by me

Help me to add more translations!


1.7.5 (2014-03-10):
Fixed warning about deprecated function.

1.7.4 (2013-12-09):
Fixed possible issue with Call-time pass-by-reference

1.7.3 (2012-04-11):
Updated the plugin to be able to run smoothly with PHP 5.3

1.7.2 (2011-01-06):
Removed debug code.

1.7.1 (2011-01-06):
Fixed error on search page. Added a sort order option in the widget.

1.7.0 (2010-10-07):
Updated the css classes. Now is the classes according to WordPress standards.
Removed the empty <ul> where supages were missing.

1.6.9 (2010-09-28):
Added Italian and Swedish translations.

1.6.8 (2010-09-10):
Removed debug code.

1.6.7 (2010-09-10):
Forces start level to be a value bigger than 0.

1.6.6 (2010-08-27):
Updated exclude functionality. Added the possibility to add a link to the title page.

1.6.1 (2010-08-26):
Added sort_column in the widget form. Fixed minor bug with the page ID.

1.5 (2010-08-21):
I created it.

  • http://www.spektraliz.com/ demand

    No screenshots available

  • http://www.tnyholm.se Tobias

    I added a screenshot now, hope it helps to show what this plugin does.

  • brian

    Can the sub-page list be in alphabetical order?

  • http://www.tnyholm.se Tobias

    Not ATM. I can include that in the next version. Probably within 24 hours.

  • brian

    Not to worry, figured it out. Thanks much for the plugin. Works great!

  • Pingback: Recently updated wordpress plugins: 2010.8.31 (1) | WP Note

  • http://carrollpc.com/blog/legal-solutions/ Dena

    Hello: I really like your Dynamic Subpages plugin… It seems to be one of the nicest ones. Is there a way to get the menu to show up on the Child Pages, not just the Parent pages?

  • ben

    great plugin! i recently updated to wp 3.1 and got errors… line 53, trying to get property of non-object in global $post var. killed it. I wanted to know if you have seen this and/or intend to fix before I start messing around myself.


  • http://www.tnyholm.se Tobias

    Dena: That should work, try set ”start level”. If you not getting it to work. Wait a while for the next version. (probably at the end of the week)

    ben: I have not heard of that bug. I’ll check it out and fix it before the weekend.

  • Ben

    Awesome. It seems peculiar… your plugin is definitely the best I found out there- I was surprised that it suddenly didn’t function.

    Let me know if I can provide you with any more info. Feel free to email me if it helps.

  • NeoMod

    Great plug-in. If are still in search for translators let me know.

  • Jesper

    Great plugin. I have one issue though – when viewing a 2nd/3rd level subpage, the parent loses it’s css class. When using the built-in menu structure in WordPress, the parent/ancestor of the current subpage has a ”current-page-ancestor” class..

  • Jesper

    Oh yes, and one more thing – even when there are no subpages of the current page, there’s an empty ?

  • http://www.tnyholm.se Tobias

    Hi Jesper,
    I’ll try to improve the plugin according to your comments. I hope to get it done this week.

  • http://dglm.smoothspider.com divya

    Hey Tobias, great, great work… There’s a small issue though… It works fine if I place it on a single sidebar.. But it doesn’t work if I place it on a second sidebar that is, I have three-four different page templates that I would like to use your widget on, but it works only on one.. Please look into this and keep up the excellent work!

  • Kevin

    Is it possible to have the sub pages displayed expanded when the parent page is first loaded? Right now you actually have to click one of the sub pages to have them shows expanded. Is there a way to have them default to open? For example http://alchemyfineevents.com/invitations/

    They are closed here, and would like them all expanded when the first page loads.


  • http://www.tnyholm.se Tobias

    Thanks a lot. I have looked at your problem, but I get it to work with more than one sidebar. Are you running the latest version of WordPress? Please contact me with the contact form at the bottom of this page if you still having problems.

    I understand what you mean. But I think isn’t very dynamic if you always is expanding every item. At the moment I consider keeping the current functionality.

  • Pingback: 70 Plugins Wordpress – Belles à bloguer

  • alf

    In Appearance>Widget>Sort Column, I set it to Post Date. How can I set it to Descending? Now is always Ascending.

  • http://www.dglofmadras.com divya

    Hi Tobias :)… You’re right, I’ve put it on different templates and it’s working fine right now.. Guess I was doing something wrong.. Just wanted to know when your next update is out coz I have a similar problem to Dena’s… If you visit this page: http://www.dglofmadras.com/holy-royal-arch/ you will see your menu.. But if you click on one of the links and visit one of those pages, the menu disappears.. Can you let me know what the setting should be so that this doesn’t happen… (Right now it’s Use parent title – yes, Start-level – 1, depth – 2).. But I’ve tried changing the depth to 3, 5, 10 etc.. and no change.. Problem is I think the widget picks up on the subpages associated with a page, but when you visit the subpage, because it isn’t a parent, no other pages show… Please help if you can… Thanks :)

  • Pete

    Everytime i use the searchfunktion it outputs an Errorcode:
    ”Warning: in_array() [function.in-array]: Wrong datatype for second argument in /xy/path/12345678/xx/yyyyyy/wp-content/plugins/dynamic-subpages/dynamic-subpages.php on line 91″
    And only on pages with the dynamic subpages widget.
    I found on line 91: ”(in_array($page->ID,$ancestors)?’ current-page-ancestor” – but i have no idea what causes the Error.

  • Britt

    Hi! I was using version 1.7.0 of your plugin and IT WAS GREAT! Then I upgraded to the new version of 1.7.1 and now it breaks my site with an error that says Array ( [0] => 32 [1] => 457 ) Is there anyway I can receive an older version of the plugin? Unfortunately I didn’t archive the 1.7.0 version before upgrading. Thanks!

  • http://www.tnyholm.se Tobias

    Sorry Britt, I forgot to remove the debug code. I have just updated the plugin to 1.7.2

  • Britt

    Thanks Tobias!

  • peter

    Thanks Tobias for the update… it works. Kiitos!

  • scott


    GREAT Plugin! Had a quick question, I have a site where on the third subnav I want to be able to add a .pdf to the dynamic subpgae nav… anyway to do that?


  • Alyson

    Hello! Grants so much for this plugin!

    when I saw the purpose of your plugin, I was very happy to know that I could do what my boss ordered rs

    He asked me to, clicking on the main menu it up in some subcategory …
    On the left sidebar, to show the subcategories of this subcategory.
    And dynamically changed according to these subcategories …
    subcategory also changed.

    Your plugin seems apt that this, right?

    I have the latest version of wordpress and your plugin
    My thema has two sidebars.
    When I installed your plugin,that was installed in the sidebar ,disappeared and did not appear.

    Could you help me?

  • http://www.tnyholm.se Tobias

    I really dont understand your question, this plugin does not have anything to do with categories… I will send you an email..

  • Gege


    very nice plugin ! thanks !

    I have a little problem with multilanguages. I use qtranslate, i have 3 languages and the problem is that the three languages are displayed in the title…
    Have you an idea to correct this ?
    thank you

  • Toto

    Thank you very much for this plugin.
    1 Question:
    It does not work together with seo plugin like
    #All in One SEO Pack
    #WordPress SEO
    for example, i would like to change the menu-lable and the link-title. Is there a chance to make this possible?
    Thx in advance

  • kimbedi


    great plugin but I have a small query

    is there a way of setting a different css class for each parent/custom title so that e.g. you could have a different colour for each parent subpage text


  • http://designscope.net Tobi

    Hi Tobi,

    thank you very much for this Plugin which makes life much easier when using WordPress as CMS.

    Every now and then I have to deal with more than one language and I am then installing the qtranslate plugin for multi language capability. There is one ”issue” in line 131 of your plugin code.
    May I ask you to alter $title to __($title) to make your plugin multi language compatible, just for the next revision?

    Thank you again.
    Greetings to Sweden

  • http://lnx.reameincantato.it/ilgrv/ Maurizio

    Hi, is it possible start to show subpages from ”corrent” subpage and not from a ”fixed level”?
    In this way I can have a menu always ”clear” with only the related sub menu.

  • ted


    This plugin helps me a lot.  Thanks.  But I too am wondering if i can change the style a bit.  How would I have the current page display in a different color? Not be absent?

  • http://www.tnyholm.se/ Tobias Nyholm

     You use the standard wordpress classes. Since 1.7.0 we have includes ”current_page_item” if I remember it correctly.

  • Anton42

    Hi, this looks like a very good plugin, but when I try to activate it I get the following error:

    Fatal error: Call-time pass-by-reference has been removed in wpwp-contentpluginsdynamic-subpagesdynamic-subpages.php on line 153 

    Is it something that I configured wrongly? 

  • http://www.tnyholm.se/ Tobias Nyholm

     Hi, No you have not done anything wrong. You just have a more up-to-date php version than I have. I have updated the plugin now. You should see an update within an hour.

  • http://www.amaslo.com/ Anton

    It is on row:

    I tried removing the ampersand, as someone recommended, the plugin activates, but the widget is not displayed in this case. I guess the recursion does not work without passing by reference.

  • http://www.amaslo.com/ Anton

    Thanks, it activates now, but I still don’t have the widget displayed on any of the pages of the site. Is there some way to debug it?

  • http://www.amaslo.com/ Anton

    Hmmm, I have learnt a lot about WP debugging, and now see that I may have had a wrong idea about what the plugin does.
    Can you please confirm – it determines the subitems only by the parent pages (using get_post_ancestors), and does not use category structure? Is it possible to display subpages for a category in a widget this way, or am I missing some very easy standard method to do it?

  • http://www.tnyholm.se/ Tobias Nyholm

     The plugin does only work on pages. Not categories. I don’t know a simple way to display categories dynamically. But you can always define a custom menu or use the category widget.

    Btw, I sent you an email yesterday.

  • http://www.amaslo.com/ Anton

    Tobias, thanks for your help, I understand it better now.

    I didn’t receive your email, unfortunately, not even in spam :( I’ll try to email you in case you still need it.

  • Glucas

    By default the plugin picks up the css from the main thesis nav. I’d like to be able to override this and have the subpages have their own css styles. Suggestions?

  • http://www.tnyholm.se/ Tobias Nyholm

    Sure. It is just to add CSS to your template. The plugin does not have any CSS by itself. I have put some ids on divs to make it easier for you. 

  • Grady Lucas

    On very short submenu items, the text runs together on one line rather than having a
    after each /li. How can I correct this?

    (a screenshot would be useful, but I cannot upload an image with the post; feature not working).

  • Pingback: Dynamic Supages | Best Plugins - wordpress – widgets – plugin 2012

  • Kevin Busch

    At first: Great Plugin!
    Second: My Blog-Page as a Subpage doesn’t work

    For example i have the following pages:

    |-About us
    |–We are
    |–News read -> Blog)

    If i am in ”About us”, ”We are”, ”blubb” i can see the SubpagesMenu.
    But if i am at ”News” i can’t see the Menu. Also if i click on a BlogPostItem to see the details, i a have no Menu.

    Has anyone the same problem?

  • Kevin Busch

    Oh, i should read the ”support” page on WordPress first :)


  • MacMacs

    Hello Tobias,

    I really like your plugin!! But unfortunately there is a w3 error (http://validator.w3.org/check), if there are no suppages.

    > Text not allowed in element ul in this context.


    > Content model for element ul:> Zero or more li and script-supporting elements.
    This can be fixed by changing line 112 of dynamic-subpages.php to

    $emptyListItem = ‘ ’;

    It would be great, if you could fix this in future versions for improved w3 compatibility!