Allow for ‘Pending’ and ‘Draft’ posts to be set as post parent

I recently needed to use posts with a heirarchal structure (like pages have by default) and ran into an issue where posts still in the draft and pending stage could not be added as a parent.

This would not do as I was publishing a set of posts where I wanted more than one to be complete before sending it to the wolves.

And the survey says(!):

//allow for draft and pending posts to be set as parents
add_filter('page_attributes_dropdown_pages_args', 'my_attributes_dropdown_pages_args', 1, 1);

function my_attributes_dropdown_pages_args($dropdown_args) {

    $dropdown_args['post_status'] = array('publish', 'draft', 'pending');

    return $dropdown_args;
}

Leave a Reply

Your email address will not be published. Required fields are marked *