WordPress Widgets

=== UTW Related Posts ===

There does exist a [[http://israelsson.nu/blog/projects/wpw-related-posts/|related posts]] widget that uses the [[http://www.w-a-s-a-b-i.com/archives/2006/02/02/wordpress-related-entries-20/|related posts plugin]]. However, I wanted a widget that would use [[http://www.neato.co.nz/ultimate-tag-warrior/|Ultimate Tag Warrior]]. So I wrote up one to use that. Note that you need to have the UTW plugin installed to use this widget.

[[http://floatingsun.net/data/code/utw-related-posts.phps|UTW Related Posts]]

Though I have been using this widget for a couple of weeks now, I didn’t release it immediately. It seems another [[http://saboya.org/344/|UTW related posts]] widget was released in the meanwhile. I love open source! :-)

=== Subpages ===

When I started using the widgetised sidebar in K2, I realized that my subpages were no longer showing up when I was viewing a page. So I wrote a subpages widget — it only shows up on a page, and only if the page has some subpages.

[[http://floatingsun.net/data/code/subpages.phps | Subpages Widget]]

**Update 8/13/2007**: Updated to work with WP2.0+

**Update 9/1/2006**: I’ve added another option called “Sibling Title” to the widget. This will control the “label” for the siblings section.

**Update 8/19/2006**: I’ve added a “Show siblings?” option to the widget. When checked, it will additionally display the list of pages at the same level as the current page (hopefully). Please check it out and let me know if anything breaks.

==== Previous versions ====
* [[http://floatingsun.net/data/code/subpages-0.3.phps | Version 0.3]]
* [[http://floatingsun.net/data/code/subpages-0.2.phps | Version 0.2]]
* [[http://floatingsun.net/data/code/subpages-0.1.phps | Version 0.1]]


  1. Pingback: Two Wordpress Widgets at Floating Sun
  2. Pingback: WordPress Widgets » Blog Archive » UTW and Subpages
  3. Pingback: » links for 2006-08-11 Con nombre y apellido: Blog de Percy AvendaƱo :: Lo que veo, escucho y escribo.
  4. Pingback: The Thin Line » Elsewhere
  5. Alex

    Hi Diwaker,

    your subpage widget is great, everything worked perfect immediately. If I can make some suggestions, it would be great if the title goes away as soon there is no subpage of this page. And if it’s possible, it would be great if you click on one subpage, that the other subpages, which are on the same level, would keep on showing up on the sidebar.

    For example
    Page: City
    Subpage: Dallas, London, Tokyo and as soon you click on Dallas the links of the two other subpages go away too. Would be great if they stay there.

    Thanks again for this great plugin.


  6. Diwaker Gupta

    *@alex*: I’ve added a “Show siblings?” option to the Subpages widget. When checked, it will additionally display a list of the sibling pages. Its a bit crude (the title of the siblings list isn’t configurable for example), but that can change easily. I just want to know if this works for you.

  7. Alex

    Hi Diwaker,

    thanks for improving the plugin, but it doesn’t really work. Instead of showing just the links of the same level it is only showing the pages of the highest level, which I have in the vertical navbar.

    Hope you can make it just show the links of this specifical sublevel.



  8. Diwaker Gupta

    *@alex*: It seems to work for me (atleast for the first level pages). I suspect there might be a problem with pages at higher depths. It’ll be great if you can send me a screenshot (either upload it somewhere and post a link here, or just email it to diwaker AT floatingsun.net). Any other information you can send (such as how many levels are the pages that you are testing on nested and so on) will be useful. Thanks!

  9. Alex

    yes, with the first level pages it works. But if I have a second level page, it only shows the first level pages on the sidebar. Go to my website, http://www.derfrison.com click on “City” in the Navbar, which has Dallas/Fort Worth, Damme, Sevilla as Suppages. It should only show on the right sidebar these 3 links, instead it’s also showing under it the first level pages in German and English. And when you click on any of these 3 Cities, it should still show these 3 Cities in the Sidebar and not the links of the 1st level pages, what is current there and the links of the 3 Cities are not showing anymore.

    I just don’t want to show the links of the 1st level pages on the right side, since they are always in the navbar at the top. It just should show, in the example of City the 3 links for the cities, and also if I’m going to one of the pages of the city, it still should show the 3 cities.

    Hope I did explain it good enough.

    Thanks a lot for your help. I appreciate that.


  10. Diwaker Gupta

    *@alex*: Thanks for the details. Yeah, I suspected this problem :( I’m looking through the Codex to figure out some API issues. Hopefully it shouldn’t be too hard to do. Once again, thanks for your patience :-)

  11. Diwaker Gupta

    *@alex*: Alright, I think I’ve finally got it right. You should now see the correct list of siblings (meaning pages with the same parent as the current page). Additionally, the current page itself is excluded from the list. Let me know if this works for you.

  12. Alex

    Hey Diwaker,

    looks you are on the right way, just two things, everytime I clicking on one of the links in the sitebar, it shows Siblings on the top instead of Subpages, which I put in the field of the widget admin. It only shows the topic “Subpages” when I click on the link City, when it shows all three Cities on the right side.

    Another thing, I don’t know, but maybe some people like to see still the link of the actually page on the right side. Right now, if I click on Sevilla, it only show the other two Cities. Would be great if you can make a selection in the widget admin, if you want to show existing page in the link list or not.

    By the way, I never get notify when you write a comment, that’s why I’m writing back so late sometimes.

    I try it now with another email address, I will let you know if I got a notification.

    Thanks for doing this great plugin


  13. Diwaker Gupta

    *@alex*: I’m not sure I follow. I went to your site and clicked on all items on the top menu (“About Us”, “City” etc). On “About Us” for instance, I see neither “Siblings” nor “Sub pages” which seems to be the right behavior — the page doesn’t have sub pages, and the widget is coded not to show siblings for “top-level” pages.

    On “City”, it just shows “Subpages” which is also correct. On “Dallas” is just shows “Siblings” and no “Subpages”. Looks perfectly consistent, and desired behavior to me. If you could point me a specific URL that is causing the problem, that would be great.

    As for not getting notified — I’m not sure. The subscribe-to-comments plugin seems to be working fine for me and others.

    I’ll think about adding the option to display the current page in the sibling list. Thanks for all the testing!

  14. Alex

    Hi Diwaker,

    because of “About Us” you are right, there are no subpages. And like you said, everything is correct. I just ment the word “Siblings” at the top of the links when you clicked before on one of the cities. It would be great if it wouldn’t say “Siblings”, it would say the same word like it was before. In my case “Subpages”.

    If you click on City, then you see 3 links to the Cities and as a header “Subpages” , when you select one of these 3 Cities, you see the other 2 links to the cities and as a header the word “Siblings”. This word should be the same word, like I put in the admin widget as header, in this case “Subpages” and not “Siblings”.

    Hope you could follow me know.

    Thanks in advance and have a great day


    P.S I didn’t get a notification with the other email either, so it looks like it’s not working.

  15. steffen

    Hi mate

    the Subpages Widget is VERY VERY good, awsome indeed..

    would it be possible to edit the sibbling word by something different

    also do you think it would be possible to have the master category showing on top for example at the widget title place? just like to make a small index of the subpage of a given master page?

    thanx you again for your time, very great widget

  16. Diwaker Gupta

    *@steffen*: Thanks, I appreciate it.

    I’ll think about the option to change the text “Siblings”. The problem is that you might want different text to replace “Siblings” depending on which sub pages you are viewing, and that doesn’t seem easy to do. I can add an option for a global replace (so it would always read “Cities”, for instance), if that helps.

    *@alex*: yeah, I think I understand what you’re trying to say now. I’m still not sure how meaningful it is though.. I mean sub pages and siblings to me mean two entirely different things and so it seemed natural to have different names. Anyways, I’ll see if I can come up with some options that’ll keep you happy.

  17. Alex

    Hmm, for me it’s not a big difference between Siblings and Subpages. I know what you mean, but I wouldn’t make a big difference to it. But I think instead of “Siblings” to have the Name of the Master Category (in my example “City”) of the specific subpages would be great. Hope you can make it happen.

    By the way, your notification works now.

    Have a great day


  18. Pingback: Bloggy Widgets » Blog Archive » A widget for WordPress Pages: Subpages widget
  19. Diwaker Gupta

    *@alex*: Hey man, sorry for the delay, I’d been busy with other things. Just so you know, I’m always open to patches! :) Meanwhile I’ve added a “Sibling Title” option to the widget — hopefully that will fix your problems. As I mentioned earlier, this is a global setting — so you can’t (yet) configure the labels on a per-page basis or anything. Cheers!

  20. Diwaker Gupta

    *@neville*: IIUC, you can only use those widgets that are provided by WP.com for you. So technically yeah, the widget should be usable by WP.com blogs, but only if WP.com provides that widget for you to use.

  21. Alex

    Hey Diwaker,

    no problem with the late response, I’m glad that you are working on it. And you are going the right way, hopefully you can make it to automatically taken the name from the master category one day :) that would be perfect then. I put the new version online but it showed me following error:

    Warning: Cannot modify header information – headers already sent by (output started at /homepages/45/d156672994/htdocs/derfrison/wp-content/plugins/subpages.php:85) in /homepages/45/d156672994/htdocs/derfrison/wp-content/plugins/ImageCounter/ImageCounter.php on line 47

    so it’s messing up with my Image Counter plugin. Is there a way to fix that?



  22. Diwaker Gupta

    *@alex*: just try reloading the page, flushing wp-cache if you have it enabled etc. There doesn’t seem to be anything different in the plugin (in terms of stuff it does) that wasn’t present before, so its unlikely that the new version is causing those conflicts.

  23. Alex

    Cool, it’s working now :) . Hope you are still trying to have an option where you can automatically have in the Siblings Title the name of the current Masterpage

    Have a great day and thanks again for this great plugin


  24. David Bovill

    Hi, cant get the Subpaes widget working with the unsleepable theme (1.7 widgetised) – nothing shows at all? That is after installing the widget I can use the widget sidebar interface and drag the subpage to the sidebar – but there is nothing visible.

    I”ve had to revert back to the non-widgetised 1.6 theme… not sure why it is not working?

  25. Diwaker Gupta

    *@alex*: Glad its finally working for you! I’ll keep that request on my _eventual_ TODO list :-)

    *@david*: Unsleepable is just a K2-mod, so I’m not sure why its not working (I use K2 from SVN myself on this site). Check your webserver logs — do you see any errors there?

  26. Pingback: Sub-pages widget at UnlimitedInfinity
  27. Pingback: Bloggy Widgets » Blog Archive » It all relates together - a related post widget
  28. Doug Weathers

    Hi Diwaker,

    Thanks for this plugin! Very simple and effective. I’m using it with K2.

    A suggested enhancement: pay attention to the “Page Order” parameter and sort the list of pages accordingly. No matter what numbers I put in the Page Order box on a subpage, your widget lists the subpages alphabetically.

    Not a huge deal, though.

    Thanks again,


  29. Pauline

    Aha, I was just looking around to find a solution to that order thing too. I have subpages that need to be listed in order. Got around the alphabetical limit by sticking numbers at the front of the titles – but that only works up to 9.

    Really like the subpages module! Hoping it picks up the page order in a new release? ;-) Happy New Year, and thanks!

  30. Mark S. Meritt

    I love the Subpages widget — it does just what I was hoping to do! A question: would there be an easy way to hack the widget so that a single main page and its subpages all had a particular logo image displayed above the subpage list? I certainly know how to do the HTML to grab and display an image, I just wouldn’t know how/where to put it within the subpages.php code and how to make it conditional, being only for that particular page and its subpages.

  31. Mark S. Meritt

    Hey, there, another couple of small things. First, I’ll lend my support to the request for page order to be recognized! Beyond that, I notice that for my pages that have no subpages, I get an emptpy box showing up in my sidebar. It would be ideal of the subpages widget just made sure to display nothing at all in those cases. Possible? Or is this a theme/CSS issue and not a widget coding issue at all?

  32. Mark S. Meritt

    I just installed your UTW Related Posts widget, and that’s really great, too! One strange bit of activity that isn’t the widget’s fault, but maybe you have some insight:

    When I first installed UTW and had it automatically display tags on all posts, it turned out that this caused a strange behavior. Because I also had it automatically adding Categories as Tags, it was taking my default Category and adding is as a Tag even on my *pages*, not just my posts. That word then showed up, bizarrely, on all my pages. I had to have UTW stop automatically displaying tags everywhere, instead adding it only as I wished on particular templates. That fixed that.

    However, now, even a tag archive shows only posts and not pages, when I go to a post that is in my default category, lo and behold, your UTW Related Posts widget shows a number of my pages!!! I’m guessing that UTW is somehow continuing to add that default category as a tag even on all my pages. An archive knows to only look for posts, but your widget seems to look for everything. Do you know if:

    1) There is a way to eliminate that default item from the pages somehow, and/or

    2) If you can revise your widget to act just like tha archive, looking only at posts and not both posts and pages?

  33. Mark S. Meritt

    FYI, I solved that last issue I mentioned. I just went into the code for your widget and change the line that says:

    if ( is_single() || is_page() ){


    if ( is_single()){

    And that was that! Wonderful. You might consider adding an option to the widget so that people can choose whether it appears on posts, pages or both. But in the meantime, this certainly works fine for me.

  34. kretzschmar

    siblings do not work for me. i am using wordpress 2.1 and i get a MYSQL Error. You have to change:

    get_var(“SELECT post_parent FROM $wpdb->posts WHERE ID = $current_page”);


    get_var(“SELECT post_parent FROM $wpdb->posts WHERE ID = ‘$current_page’”);

    Hope my corrections are shown. Otherwise, current_page needs to be in single quotation marks.

  35. kretzschmar

    My own Navigation on diekretzschmars is broken since the update to wordpress 2.1. I am not very good at querying the database.

    I would like a back-link. So if I am on a Subpage a link to the parent page is listet (maybe named back).

  36. Pingback: My WordPress plugins | rich text
  37. Thomas

    How about a show self option to the sibling part of the sidebar widget? I might try to make it myself, but I’m not really a programmer. I’ll let you know if I do.

  38. Matt

    Hi , it looks like your plugin does pretty much what I want, but whenever I activate it I get this error:

    Fatal error: Call to undefined function: register_sidebar_widget() in /home/m/a/mattkevan/public_html/wp-content/plugins/widgets/subpages.php on line 72

    Any ideas of what’s going wrong?

    Thanks for your help!


  39. Eric

    @Matt: I had exactly the same problem. For the record, I did have the Widgets plugin installed, working correctly, and hosting other widget-based plugins.

    Did a little digging around and it looks like the registration sequence in the plugin is incorrect. For some reason, WP chose to load the subpages plugin before it loaded widgets plugin on my server, so the call to register_sidebar_widget was hitting the dreaded undefined error.

    I replaced the two register_ calls at the end of the file with the following sequence, and all was good with the world:

    function subpages_init() {
    if ( !function_exists(‘register_sidebar_widget’) )

    // Tell Dynamic Sidebar about our new widget and its control
    register_sidebar_widget(‘Sub Pages’, ‘subpages’);
    register_widget_control(‘Sub Pages’, ‘subpages_control’);

    add_action(‘plugins_loaded’, ‘subpages_init’);

    Unfortunately, it looks like this plugin isn’t going to do what I need it to do, but I hope this info helps.

  40. Sebastian

    Cool Widget!

    You’ve to change the code as followed:
    at the top of the code put following
    function subpages_control_init() {
    and at the end of the file please insert
    add_action(‘plugins_loaded’, ‘subpages_control_init’);

    So it work’s fine for me.
    Best regards from good old Germany to all of You!

  41. Nice from Thailand

    Can some one tell me how to fix this plugin to work with WP2.2?

    Fatal error: Call to undefined function: register_sidebar_widget() in /home/m/a/mattkevan/public_html/wp-content/plugins/widgets/subpages.php on line 72

    I tried Eric and Sebastian’s code but it doesn’t work.

  42. Pingback: WP Plugins DB » Plugin Details » Sub pages
  43. Pingback: WP Plugins DB » Plugin Details » UTW-Related Posts
  44. Diwaker Gupta

    *@nice*: I’ve updated the widget — it should work with the latest WordPress now. Sorry for the delay, and do let me know if you’re still having any problems!

    *@sebastian*: Thanks for trying to help out! I’ve finally updated the widget :-)

  45. Pingback: Web Services » Better Blog Day 4: Interlinking Posts
  46. Mark S. Meritt

    Hello again, thanks for updating the widget. I notice, though, that there is still an issue I’d commented about back in January that I imagine many people would probably like to see addressed.

    When a Page has neither sibling pages nor sub pages, your widget produces an empty box that clutters the sidebar. I think it would be ideal if the widget would display nothing at all under these circumstances, just as it shows nothing on non-Pages like posts and archives.

    Thanks for your consideration, and thanks again for the plug-in!

  47. Mark S. Meritt

    Quick correction on my last comment. The empty widget box appears in two situations — it appears when:

    1) A top-level Page has no sub pages, even if it has sibling pages


    2) A sub page at any level has neither sibling pages nor sub pages

Leave a Reply