Create a “Dummy” parent page for a hierarchy in page listing?

Is it possible to set up a “dummy” page – just a page title that appears in the page listing, and a page that is not editable and doesn’t have a slug?

This is more of a hypothetical question, as I don’t know where to start with code or determine the best way to go.

I’d like to have the option to set up such a parent/child hierarchy in the page listing so that the child pages fall under the parent, but the parent page is just a placeholder and not a real page.

The reason: for users without lots of experience in WordPress, it’s helpful to organize pages in a parent/child hierarchy – especially if there are lots of pages – so that that related pages are more organized in the page listing. Users can also visualize building a menu, too, if child pages are organized under a parent. The problem is the parent page can be editable and not part of the established page content, and in my experience, this leads to user confusion.

I can use a function to remove the editor for a specific page and use entires in robots.txt to not index the dummy parent, but that means changing those for a new parent. And that parent page still has a slug, even if blocked wit

So is there a way to create a function that creates a page title and with the ability to assign child pages, but have the parent page unopenable, uneditable and not have a slug?

enter image description here

Solutions Collecting From Web of "Create a “Dummy” parent page for a hierarchy in page listing?"

OK here is my attempt, it is pretty hacky and in the end I was not able to remove the link/color of the parent item, but the parent link will not work.. so it kinda works.

First create a CPT with the following params set:

$args = array( 
        'hierarchical'        => true,
        'public'              => false,
        'show_ui'             => true,
        'show_in_menu'        => true,
        'capability_type'     => 'post', 
        'supports'            => array( 'title','page-attributes' ),
    );

Fill in the rest as needed, this will enable you to have a parent post/page that shows in the admin but not on the front end, it also allows parent functionality via page-attributes.

Now we can throw in a filter that removes the small “edit”, “view” and “trash” links for the parent.

function wpse_95518($actions) {

    global $post;

    //rename this to your CPT 
    if ($post->post_type =="parent"){
        // check if it's a parent
        if ( ! (is_post_type_hierarchical('parent') && $post->post_parent )) {

            unset( $actions['inline hide-if-no-js']);
            unset( $actions['trash'] );
            unset( $actions['view'] );  
            unset( $actions['edit'] );
        }           
        return $actions;
    }
    return $actions; 
}

add_filter('page_row_actions', 'wpse_95518');

Now things get a bit funky, to remove the parent title link functionality to edit the post.

function wpse_removetitle_95518($action){

    global $post; 

    if ($post->post_type =="parent"){
        if ( is_post_type_hierarchical('parent') && $post->post_parent ) {
            return $action;
        }else{
            return '#'; //just in case
        }
    }
    return $action;
 }
add_filter( 'get_edit_post_link', 'wpse_removetitle_95518');

Now parent items of the CPT should not be editable via links in the admin, it will show as edit.php?post_type=parent# but the children will be ok.

The downside is that the parent item will still be a blue link instead of black text, I could not find any simple way to remove the link from the title or add custom CSS to do it via javascript without extending the WP List Table.

You can of course alter the parent title using the_title filter but even setting it to NULL via the above conditional still shows a < a href=..>

Also there might be a simpler way to do all of this just using the is_post_type_hierarchical filter.

Github link to Table Class code for the title.