Force category choice before creating new post?

Posted by Prem Tiwari | Updated on

I solved this by hooking into post-new.php, and checking for a category_id request parameter. If it does not exist, I display a form with a category dropdown that submits back to this page, and then call exit() so the regular post form does not display. If it exists, I set up a hook for wp_insert_post that will add the category.

This works because a new post is already created in the database via the get_default_post_to_edit() function, and we can add categories, tags, or other (meta) content. The form is rendered after this with the “fresh” new content.

If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@] Your question and answer will appear on and help other developers.

Related Questions & Answers