There is a function called get_page_by_title
that accepts a post title and returns the ID of that post. You might even use it in conjunction with get_edit_post_link
by passing the ID and retrieve the edit link.
However, how can you be sure the post’s title will never change? You could go a little further and add a settings page where you would map a particular post / page to an entity such as HOME_ID
, ABOUT_ID
etc. Then, instead of using the get_page_by_title
you would just have this settings array
and you could build those add_menu_page
calls like this:
if ( ! $user->has_cap( 'manage_options' ) ) {
$options = get_option( 'wt_menu_post_ids', array() );
add_menu_page( 'Home', 'Home', 'edit_posts', get_edit_post_link( $options['HOME_ID'] ), '', 'dashicons-admin-home', 1);
// [...]
}