Using WordPress ‘quick_edit_dropdown_pages_args’ PHP filter

The quick_edit_dropdown_pages_args' WordPress PHP filter allows you to modify the arguments used to generate the Quick Edit page-parent drop-down.

Usage

add_filter('quick_edit_dropdown_pages_args', 'my_custom_dropdown_args', 10, 2);

function my_custom_dropdown_args($dropdown_args, $bulk) {
    // Your custom code here
    return $dropdown_args;
}

Parameters

  • $dropdown_args (array): An array of arguments passed to wp_dropdown_pages().
  • $bulk (bool): A flag to denote if it’s a bulk action.

Examples

Exclude a specific page from the dropdown

add_filter('quick_edit_dropdown_pages_args', 'exclude_page_from_dropdown', 10, 2);

function exclude_page_from_dropdown($dropdown_args, $bulk) {
    $dropdown_args['exclude'] = array(42);
    return $dropdown_args;
}

In this example, we exclude the page with ID 42 from the page-parent dropdown.

Only show pages from a specific author

add_filter('quick_edit_dropdown_pages_args', 'pages_from_specific_author', 10, 2);

function pages_from_specific_author($dropdown_args, $bulk) {
    $dropdown_args['authors'] = '5';
    return $dropdown_args;
}

Here, we only show pages created by the author with ID 5 in the page-parent dropdown.

Sort pages by date in descending order

add_filter('quick_edit_dropdown_pages_args', 'sort_pages_by_date_desc', 10, 2);

function sort_pages_by_date_desc($dropdown_args, $bulk) {
    $dropdown_args['sort_order'] = 'DESC';
    $dropdown_args['sort_column'] = 'post_date';
    return $dropdown_args;
}

This example sorts the pages in the dropdown by their creation date in descending order.

Show only published pages

add_filter('quick_edit_dropdown_pages_args', 'show_published_pages_only', 10, 2);

function show_published_pages_only($dropdown_args, $bulk) {
    $dropdown_args['post_status'] = 'publish';
    return $dropdown_args;
}

In this scenario, we modify the dropdown to display only published pages.

Limit the number of pages in the dropdown

add_filter('quick_edit_dropdown_pages_args', 'limit_pages_in_dropdown', 10, 2);

function limit_pages_in_dropdown($dropdown_args, $bulk) {
    $dropdown_args['number'] = 5;
    return $dropdown_args;
}

This example limits the number of pages displayed in the dropdown to 5.