PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, March 12, 2022

[FIXED] WordPress admin: show draft pages in page attributes parent page dropdown

 March 12, 2022     wordpress     No comments   

Issue

For clarity - here is a picture of the box I am talking about in this question: Screenshot of post parent dropdown list

Background: I have built a relatively complex WP site for a client which is more of a CMS than a blog and relies on a hierarchy of pages being built. (Well, they're actually custom post types with 'hierarchical' => true set)

My question: is it possible to show draft (or pending review) pages in the page attributes 'Parent page' dropdown list? Without this, it means making each page live before the whole section is ready - and that's not a suitable solution.

What I've tried:

  • Looking for an action which gets called to build the list (can't find one)
  • Looking in the source code for where the list is created (it's built with wp_dropdown_pages which doesn't appear to let you choose the post status)
  • Looking for plugins which provide this functionality

Solution

Very nice question!

The following does it. One filter is for the edit page screen and the other for the Quick Edit menu.
Tested with a hierarchical custom post type.

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

function so_3538267_enable_drafts_parents( $args )
{
    $args['post_status'] = 'draft,publish,pending';
    return $args;
}

drafts enabled as parents



Answered By - brasofilo
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing