Add new WordPress page with preselected parent

I do not want my clients to select a parent page from the drop down list, when creating a child page in Wordpres, so I would like to now if there is a way to create a link on the dashboard which links to “add new page” – but with a preselected parent page?

If this is not possible, then is there a way to change the default parent from “(no parent)” to a parent of my choice?

Related posts

Leave a Reply

2 comments

  1. Put this script in your plugins folder and it’ll give new pages a parent of whatever you set as $parent_id

    <?php
        function set_parent($content) {
            /* >> Begin user-configurable variable >> */
            $parent_id = '1'; // ID for parent page >> */
            /* >> End user-configurable variable >> */
            $pattern = "option value='{$parent_id }'";
            $replace = "option value='{$parent_id }' selected="selected"";
            $content = str_replace($pattern, $replace, $content);
        return $content;
        }
    
    if( strstr($_SERVER['REQUEST_URI'], 'wp-admin/post-new.php?post_type=page') ) {
    ob_start('set_parent');
    }
    ?>
    

    That should do what you want. And I suppose you could add a dropdown option in somewhere to select parents if a set default parent isn’t sufficient like in this example.