I’m trying to add a custom link under my Post Type in my admin menu, which will link to Pending Posts. This code functions, but it instead makes a page (like I suppose the function should), but I just need a single link and there doens’t seem to be a add_submenu_link
function unfortunately. Is there a way to create a static link but place it in my post type submenu?
/** Add Pending Posts to WP Admin Menu **/
function add_custom_link() {
add_submenu_page('edit.php?post_type=cpt_custom', '', 'Pending Posts', 5, __FILE__, 'sub_page_pending');
}
function sub_page_pending() {
echo '<li><a href="edit.php?post_status=pending&post_type=cpt_custom">Pending Posts</a></li>';
}
add_action('admin_menu', 'add_custom_link');
I’ve tried to use a wp_redirect()
but I get some errors telling me that the headers have already been set.
Insert the URL of the page as the
$menu_slug
argument. Also note that user levels are deprecated, you should pass a capability instead.