I want to add a new menu point to post that shows posts of a certain category. Adding a new page is easy if it is just a new post type. But I want to only show posts with a specific category and when updating posts make sure the category is checked.
IS there no way of doing this? I was hoping for some simple functon, like the way register_post_type() does it. As there doesn’t seem to be, does anyone give me any tips about how to do this? Is it even possible? Or should I just use a custom post type?
3 Answers
You can filter the posts list by appending ?category_name=xx
to the admin posts list URL, and you can add a submenu page with that URL as the target via add_submenu_page
:
add_action( 'admin_menu', 'wpd_admin_menu_item' );
function wpd_admin_menu_item(){
add_submenu_page(
'edit.php',
'Page title',
'Menu item title',
'edit_posts',
'edit.php?category_name=somecat'
);
}