Hierarchical List Pages as a table
I need to generate a list of all WordPress Pages and have them display in a HTML Table, that will be printed for offline use.
- First column is Blank
- Second column will have the Page Creation Date
- Third column will have the last Page Modified Date
- Fourth column will have the Page Title
However, the Pages need to be listed by
menu_order and if a Page is a child of the one above it, that Page Title will need to be intended.
Basically, I need something similar to the WordPress “All Pages” list, but in a simple table format and only the information above.
I have searched Google for several hours and have found some code snippets, but nothing has worked.
wp_list_pages will not allow me to display both Creation and Modified Dates at the same time, nor can I get the formatting I need.
get_pages is closer, but I don’t know how to get the formatting and indentation of sub-pages the way I need.
I am able to get a Hierarchical List in exactly the order I need to, but still need to figure out how to Indent the Subpages. Within the Page Data of each page, is its original ID as well as the Parent ID. What I need to do now is indent all sub pages, so that it looks like:
ID 1 PARENT-ID 0 ID 2 PARENT-ID 0 ID 3 PARENT-ID 2 ID 4 PARENT-ID 2 ID 5 PARENT-ID 4 ID 6 PARENT-ID 2 ID 7 PARENT-ID 0 ID 8 PARENT-ID 0 ID 9 PARENT-ID 8
Data is being outputted in that exact order.
CODE IS FROM Wp get all the sub pages of the parent using wp query – Answer Entitled “Recursively Get All Current Sub-Pages” which will return a multi-dimensional array containing all Post Data I need.
I know it is just a matter of comparing the Parent ID of the current record, and if it matches the ID of a page one level above, to then indent it… I just don’t know how to do that in a simple function, where the depth of any record can be any number.
>>> Share a link to this question, just copy and paste the code bellow on your web page <<<
Hierarchical List Pages as a table</a>