Keep Page hierarchical order on Control Panel when I use ‘remove_cap’ ‘edit_others_pages’

I’m admin user and just created several editor users who are ‘NOT’ allowed
to edit other pages.
Let me call them ‘master editor’,’editor A’ and ‘editor B’.

‘master editor’ can edit top level parent pages.
‘editor A’ and ‘editor B’ can edit child pages.

top level parent pages 1 (‘master editor’)
– child page 1-1 (‘editor A’)
— grandchild page 1-1 (‘editor A’)
— grandchild page 1-1 (‘editor A’)
– child page 1-2 (‘editor B’)
— grandchild page 1-2 (‘editor B’)
— grandchild page 1-2 (‘editor B’)
top level parent pages 2 (‘master editor’)
– child page 2-1 (‘editor A’)
— grandchild page 2-1 (‘editor A’)
— grandchild page 2-1 (‘editor A’)
– child page 2-2 (‘editor B’)
— grandchild page 2-2 (‘editor B’)
— grandchild page 2-2 (‘editor B’)

I could realize this writting the source below on functions.php:

function my_remove_caps(){
$role = get_role( ‘editor’ );
$role->remove_cap( ‘edit_others_pages’ );
}
add_action( ‘admin_init’, ‘my_remove_caps’ );

The problem is when I log in as ‘editor A’,
Control Panel shows the pages like this:

– child page 1-1
– child page 2-1
— grandchild page 1-1
— grandchild page 1-1
— grandchild page 2-1
— grandchild page 2-1

I mean hierarchical order looks destroyed and hard to get
which is the parent page of ‘grandchild page’.

I want it shows like this:

– child page 1-1
— grandchild page 1-1
— grandchild page 1-1
– child page 2-1
— grandchild page 2-1
— grandchild page 2-1

or more ideal

top level parent pages 1
– child page 1-1
— grandchild page 1-1
— grandchild page 1-1
top level parent pages 2
– child page 2-1
— grandchild page 2-1
— grandchild page 2-1

Is there any way to keep hierarchical order on control panel?

I’m not a native English speaker and feel sorry about my poor English.
Hope you understand.
Thank you!

Read more here:: Keep Page hierarchical order on Control Panel when I use ‘remove_cap’ ‘edit_others_pages’

Leave a Reply

Your email address will not be published. Required fields are marked *