Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
无论用户如何,我都想将自定义帖子类型的帖子数量限制为最大(例如 5 个帖子)。例如,假设我有名为 CUSTOMPOSTS 的自定义帖子类型,如果其中有 5 个帖子,则没有人应该能够创建新帖子(无需先删除其他帖子)。
可以做到吗?
亲切的问候!
有多种方法可以做到这一点。但最简单的方法是连接wp_insert_post并阻止它工作。您可以强制每个新帖子发布,draft直到他们删除/取消发布旧帖子,当他们这样做时,您可以允许他们发布新帖子。
wp_insert_post
draft