0

wp_list_pages can be a great tool for displaying a tree structure. You can specify the depth, child of, and show_date of when the page was last modified.

However, if I want to only show the date for pages that were modified in the last...24 hours say...How can I specify this?

1 Answer 1

0

By default the function cannot do this, but you can specify a custom walker when you call the function, and then implement your own walker:

http://bugssite.org/blog/2009/12/08/wordpress-custom-walker-tutorial/

http://www.wprecipes.com/how-to-modify-lists-like-categories-and-blogroll-in-wordpress

This way you can keep the code the same, but add a check on the date of the page being walked over, and 'skip' it if it doesn't match your requirements ( or add other desirable markup etc ).

more:

http://codex.wordpress.org/Function_Reference/Walker_Class

http://erikshosting.com/wordpress-tips-code/building-a-wordpress-walker-creating-custom-dynamic-menu-outputs/

http://www.maltpress.co.uk/2011/09/just-a-quicky-wordpress-custom-nav-walkers/

http://resources.mdbitz.com/2010/08/creating-a-wordpress-custom-page-walker/

4
  • So in combining those two tutorials, I would add a filter as such: add_filter('wp_list_pages', 'my_filter_function'); ? Also, I find it strange that much of documentation on the codex is missing! Thanks for the help though!
    – AlxVallejo
    Nov 16, 2011 at 19:05
  • no no, when you make the call to wp_list_pages, pass in a custom walker object of your own creation, and it will use that object instead fo the default to create the output. To make your walker object you copy paste the default, change its name, and add an if statement checking if the data for the current element is within the last 24 hours
    – Tom J Nowell
    Nov 16, 2011 at 19:54
  • By the way, do you know where the Walker_Page is located? The custom walker function extends the Walker_Page. I need to understand how that loops through each page. Currently I have wp_list_pages running with the walker executing code at each page entry (Show title + Show date modified, etc). However, I cannot get it to show the # of children in the hierarchy for that particular parent. Any ideas? Thanks.
    – AlxVallejo
    Nov 17, 2011 at 19:14
  • wp-includes/post-template.php
    – Tom J Nowell
    Nov 17, 2011 at 19:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.