0

I'd like to limit the number of posts of a custom post type to a maximum (e.g. 5 posts), regardless of the users. For example, say i have my custom post type named CUSTOMPOSTS, if there are 5 of these posts, nobody should be able to create new ones (without first deleting one of the others).

Can it be done?

Kind regards!

1 Answers1

0

There are multiple ways of doing it. But the easiest is to hook into wp_insert_post and prevent it from working. You could force every new post to draft until they delete/unpublish an older one and when they do you can allow them to publish new one.

CodeAngry
  • 12,760
  • 3
  • 50
  • 57