I use the add_menu_page function in my custom theme builds but when I export my local copy of the site and import it in the production site some of post id numbers change and I have to update this function manually (ie: in the code below: ?post=8, ?post=8, ?post=10). Is there a way to have these numbers be dynamic?
function custom_admin_menu_links() {
$user = wp_get_current_user();
if ( ! $user->has_cap( 'manage_options' ) ) {
add_menu_page( 'Home', 'Home', 'edit_posts', 'post.php?post=6&action=edit', '', 'dashicons-admin-home', 1);
add_menu_page( 'About', 'About', 'edit_posts', 'post.php?post=8&action=edit', '', 'dashicons-id', 2);
add_menu_page( 'Contact', 'Contact', 'edit_posts', 'post.php?post=10&action=edit', '', 'dashicons-phone', 3);
}
}
add_action( 'admin_menu', 'custom_admin_menu_links' );