Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

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/

share|improve this answer
    
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 '11 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 '11 at 19:54
    
Got it. Thanks! –  AlxVallejo Nov 16 '11 at 22:04
    
can you mark the answer as accepted if it got you there? –  Tom J Nowell Nov 17 '11 at 0:15
    
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 '11 at 19:14
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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