1

I have a website here with a lot of content and with the content where is necessary to create pages in hierarchy. But it is uncomfortable to go through the dropdown in the administration with a lot of pages. So my point is - in the admin at the moment i create/edit page and need to select the parent page from the list, I want to somehow filter or limit or search the list of possible parent pages. Thank you!

  • 1
    Reason for "-1" : Your question doesn't include enough information for us to give you a useful answer. You haven't even mentioned if you want help regarding frontend or backend. Please edit your question & include some details & i'll undo it. – Mridul Aggarwal Dec 12 '12 at 9:12
  • sorry, the post was edited – Karel Attl Dec 12 '12 at 9:38
  • 1
    maybe this plugin can help in page management? wordpress.org/extend/plugins/cms-tree-page-view – Mridul Aggarwal Dec 12 '12 at 10:46
2

Not sure if this will help, but I have used the code on the following page to add a parent page filter to the list of pages:

http://www.finalwebsites.com/add-a-parent-pages-filter-function-your-wordpress-admin-section/

Very handy if you have a parent page for each section.

There is just one problem - it only returns the children not grandchildren etc. I am just now trying to figure out how to get it to return results at all depths.

0

If you are using wp_dropdown_pages, then use the argument exclude_tree to exclude a parent and all of that parent's child Pages. See here for an explanation of all arguments : http://codex.wordpress.org/Function_Reference/wp_dropdown_pages

0

Found a plugin but haven't tried it: Parent Page Filter.

The following function can show children of site-root-level pages. This is useful for many instances, but unfortunately not useful if you want to filter for children of any page that is not at site root. I don't know PHP or WP well enough to suggest how to make this work on any page, instead of site-root-level pages.

function fws_admin_posts_filter( $query ) {
    global $pagenow;
    if ( is_admin() && $pagenow == 'edit.php' && !empty($_GET['my_parent_pages'])) {
        $query->query_vars['post_parent'] = $_GET['my_parent_pages'];
    }
}
add_filter( 'parse_query', 'fws_admin_posts_filter' );

function admin_page_filter_parentpages() {
    global $wpdb;
    if (isset($_GET['post_type']) && $_GET['post_type'] == 'page') {
        $sql = "SELECT ID, post_title FROM ".$wpdb->posts." WHERE post_type = 'page' AND post_parent = 0 AND post_status = 'publish' ORDER BY post_title";
        $parent_pages = $wpdb->get_results($sql, OBJECT_K);
        $select = '
            <select name="my_parent_pages">
                <option value="">Parent Pages</option>';
        $current = isset($_GET['my_parent_pages']) ? $_GET['my_parent_pages'] : '';
        foreach ($parent_pages as $page) {
            $select .= sprintf('
                <option value="%s"%s>%s</option>', $page->ID, $page->ID == $current ? ' selected="selected"' : '', $page->post_title);
        }
        $select .= '
            </select>';
        echo $select;
    } else {
        return;
    }
}
add_action( 'restrict_manage_posts', 'admin_page_filter_parentpages' );

Source

I assume this answer was first attempting to link to this page, but the link was dead. Found live link through Google.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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