0

I'm trying to get the page parent dropdown (in page attributes) to show only pages that have been published by the author of the current page.

This doesn't seem to work :

add_filter( 'page_attributes_dropdown_pages_args', 'mwm_show_only_author_pages_in_attributes' );
add_filter( 'quick_edit_dropdown_pages_args', 'mwm_show_only_author_pages_in_attributes' );

function mwm_show_only_author_pages_in_attributes( $args ) {

    global $post;

    $args['author'] = $post -> post_author;

    return $args;
}

What am I doing wrong here ?

1 Answer 1

2

From the source code the function wp_dropdown_pages uses get_pages() and this function uses different attributes than WP_Query or get_posts(). It uses authors instead of author.

Note from the codex:

authors (string) Only include the Pages written by the given author(s) Note: get_posts() uses the parameter 'author' instead of 'authors'.

2
  • Thanks david, I should really look at the source more often.
    – mike23
    Commented Mar 14, 2013 at 11:31
  • No problem, glad to help you. Commented Mar 14, 2013 at 12:04

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.