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?
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:
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.
Now things get a bit funky, to remove the parent title link functionality to edit the post.
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 toNULL
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.