I've been trying to limit the amount of posts a user can create in a specific custom post type, and I had some help from Bainternet by checking out his plugin. I read over that and then came up with my own, but it doesn't seem to be working. I want to make my code much more lightweight than an entire new plugin so I am just adding it to mine, but what am I doing wrong here?
The name of my custom post type will be lets say.. newpages. And we'll pretend $custom = 'Developer'; has been placed before the function.
function efpd_limit_posts(){
global $pagenow,$custom;
if (is_admin() && $pagenow=='post-new.php?post_type=newpages'){
$theposts = get_posts(array('post_type'=>'newpages'));
if (count($theposts) >= '1'){
wp_die('You have reached the maximum amount of 'newpages' you can create.');
} } }
add_action('admin_head','efpd_limit_posts');