I have a blog with a very complex page structure (like, 4 levels of hierarchy).

When creating new pages, it is very cumbersome to pick the parent page from the drop-down list, as it is constantly growing.

For that reason, I would like to add a button to the frontend admin bar that points to post-new.php, but with a "parent page ID" parameter. Effectively, the button would allow you to navigate to the desired parent page on the front page, and then click a "add new page here" link there that takes you to the back-end with the parent page preselected.

However, it seems to be impossible to add parameters to post-new.php and a related feature request has been closed in the WordPress trac.

Does anybody know a solution that does not require hacking the core? One idea I had was hooking up to a hook that gets triggered before a new item is created, pulling the parent page from a GET parameter there, and setting it in the item-to-be. If that is a viable way, I would be grateful for a simple pointer which hook to use.

1 Answer 1


You are right on the mark with GET, that would probably be easiest to make use of.

Try this:


class Add_Child_Page {

    static function on_load() {

        add_action( 'init', array( __CLASS__, 'init' ) );
        add_action( 'admin_init', array( __CLASS__, 'admin_init' ) );

    static function init() {

        add_action( 'admin_bar_menu', array( __CLASS__, 'admin_bar_menu' ), 90 );

    static function admin_bar_menu( $wp_admin_bar ) {

        if( is_page() ) {

            $wp_admin_bar->add_node( array(
                'id'    => 'add_child_page',
                'title' => 'Add Child Page',
                'href'  => add_query_arg( array( 'post_type'   => 'page', 'page_parent' => get_the_ID() ), admin_url( 'post-new.php' ) ),
            ) );

    static function admin_init() {

        add_filter( 'page_attributes_dropdown_pages_args', array( __CLASS__, 'page_attributes_dropdown_pages_args' ) );

    static function page_attributes_dropdown_pages_args( $dropdown_args ) {

        if ( ! empty($_REQUEST['page_parent']) )
            $dropdown_args['selected'] = (int) $_REQUEST['page_parent'];

        return $dropdown_args;
  • Beaten me on this one. I had the exact same approach, but with on exception: I think it would be a nice extension to append the link to the 'edit_post_link' filter output. This way Edit/New would stick together. Anyway +1.
    – kaiser
    Mar 18, 2012 at 14:45
  • @kaiser I think edit_post_link() gives link to edit existing post, not for new post creation.
    – Rarst
    Mar 18, 2012 at 16:18
  • Not really. The filter allows to filter the whole link string. So with »This way Edit/New would stick together.« I wanted to say, that it would be nice if you append your "new" link to the existing "edit"-$link with the filter callback.
    – kaiser
    Mar 18, 2012 at 16:42
  • Nice one, didn't know there is a page_attributes_dropdown_pages_args filter hook
    – Bainternet
    Mar 18, 2012 at 22:00
  • 1
    @Bainternet it's rather new, I was surprised it turned out so easy to hook into.
    – Rarst
    Mar 18, 2012 at 22:25

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.