5

I'm wanting to find a way to have all pages listed without paging and to do so in a method that isn't going to be over-written when I update WordPress, i.e. in the form of a hook.

The page is in the administration:
all pages

With all the pages being listed I can then use javascript to do collapsing to show/hide subpages, I'm not phased about load times of the page or anything, just cant have this method usable if paging is also used, all pages need to be listed on 1 page.

As I'm wanting to do this in the admin area, I'm not even sure if this is do-able without breaking when updating.

2
  • I'm really curious about the method you are using to expand/collapse the subpages using the default screen wp-admin/edit.php?post_type=page. Is that possible? I'm not seeing useful classes or ID's in the markup...
    – brasofilo
    Commented Jan 9, 2013 at 2:11
  • You can identify subpages by the "-" at the start of the page name, double dashes for sub-subpages etc..
    – dakine
    Commented Jan 9, 2013 at 19:06

2 Answers 2

9

If that listing has too many pages, maybe you'll run into troubles.

You probably already know that this can be set in the Screen Options of the page http://example.com/wp-admin/edit.php?post_type=page.

If you try to put a really high value there, this warning pops up and the system doesn't accept it:

1500 pages

But the following permanently sets this value to 2000.
I don't have more than 999 pages to test if that limit that WordPress is warning about will be overriden or not, but the 2k shows up after refreshing the page, and keeps there if you try to lower it.

add_filter( 'get_user_metadata', 'pages_per_page_wpse_23503', 10, 4 );
function pages_per_page_wpse_23503( $check, $object_id, $meta_key, $single )
{ 
    if( 'edit_page_per_page' == $meta_key )
        return 2000;

    return $check;
}
1
  • I thought it would be much more complicated, but yes, Screen Options did it. I think that area should always be the first place I look - kinda like checking if you have gas in your non-running engine before you look into it further. ;)
    – Mark
    Commented Mar 26, 2015 at 20:13
3

You can create a new page template, and in that template put:

<?php wp_list_pages( 'depth=-1' ); ?> 

That will list all the pages with no indentation in alphabetical order.

(Reference: wp_list_pages)

2
  • Sorry I seemed to have completely forgotten to mention the main part of this, I'm wanting to do this in the admin area, thats why im unsure if I'll be breaking future updates
    – dakine
    Commented Jul 21, 2011 at 4:03
  • You can still do what Gavin suggested. Just the wp_list_pages call within a callback for your options page or wherever you'd like it. Commented Aug 21, 2011 at 13:18

Your Answer

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

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