With the help of a couple of users, my last two questions were highlighting a custom menu item through its ID.
Now I’m trying to combine the code of the following two functions to make it work by Post Name:
Add highlighting to new Admin Dashboard Menu Item
add_action( 'admin_menu', 'create_menu' );
add_action( 'admin_head-post.php', 'wpse_58567_highlight_menu_item' );
function create_menu() {
$settings_page = add_menu_page(
'Edit_Post_69',
'Edit_Post_69',
'add_users',
'/post.php?post=69&action=edit',
'',
get_stylesheet_directory_uri() . '/editicon.png',
2
);
}
function wpse_58567_highlight_menu_item() {
global $post;
if( 69 != $post->ID )
return;
?>
<script type="text/javascript">
jQuery(document).ready( function($) {
$('#toplevel_page_post-post-69-action-edit').removeClass('wp-not-current-submenu').addClass('current');
$('#toplevel_page_post-post-69-action-edit').find('a:last').addClass('current');
});
</script>
<?php
}
and….
Convert post name into post ID
$post = get_page_by_title( $post_name, OBJECT, 'post' );
echo $post->ID;
I am now trying to combine them so that I can specify a post name instead of a post ID, can anyone point me in the right direction?