Title: Create Post Form &#8211; Category
Last modified: April 8, 2022

---

# Create Post Form – Category

 *  Resolved [beelinedigital](https://wordpress.org/support/users/beelinedigital/)
 * (@beelinedigital)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/create-post-form-category/)
 * Hi,
 * Is there a way to add a ‘create post’ form that will then automatically add the
   posts created to a specific category, rather than having to select a category
   within the form?
 * Thanks in advance,

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Kris – WPMU DEV Support](https://wordpress.org/support/users/wpmudevsupport13/)
 * (@wpmudevsupport13)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/create-post-form-category/#post-15540759)
 * Hi [@beelinedigital](https://wordpress.org/support/users/beelinedigital/)
 * I hope you are doing good today.
 * This should be possible, please follow this solution:
    [https://wordpress.org/support/topic/forminator-post-data-only-specific-article-categories-allowed/](https://wordpress.org/support/topic/forminator-post-data-only-specific-article-categories-allowed/)
 * Kind Regards,
    Kris
 *  Thread Starter [beelinedigital](https://wordpress.org/support/users/beelinedigital/)
 * (@beelinedigital)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/create-post-form-category/#post-15556735)
 * Thank you for your reply.
 * I am looking to create 3-4 forms but only want to show 1 category option for 
   each form.
 * So for example, form 1 creates posts for category ‘X’.
 * Also is it possible to set it so posts are automatically published.
 *  Plugin Support [Patrick – WPMU DEV Support](https://wordpress.org/support/users/wpmudevsupport12/)
 * (@wpmudevsupport12)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/create-post-form-category/#post-15559522)
 * Hi [@beelinedigital](https://wordpress.org/support/users/beelinedigital/)
 * I hope you are doing well.
 * Do you need to show the category on the front end?
 * If not,
 * Could you try this workaround that I believe fits well here?
 * Add this code as a mu-plugin:
 *     ```
       <?php
   
       add_action( 'forminator_post_data_field_post_saved', function( $post_id, $field, $data ){
   
         $category = (int) $_POST['hidden-1'];
         // $categories = [ 1, 2, 3 ];
   
         if( $category ){
           wp_set_post_categories( $post_id, $category );
           //wp_set_post_categories( $post_id, $categories );
         }else{
           // Default category if no category is defined on hidden field, this conditional can be removed.
           wp_set_post_categories( $post_id, [ 157 ] );
         }
   
       }, 99, 3);
       ```
   
 * Create a hidden field, set it to a custom value and then set the category ID 
   that you would like to use.
 * [https://monosnap.com/file/jM76xzMoknnr2RMLmz7P8wu9bTn7ja](https://monosnap.com/file/jM76xzMoknnr2RMLmz7P8wu9bTn7ja)
 * Remove the default category field in Post data, and then on form submission, 
   it will set to that custom category on the hidden field.
 * You can also extend the code to multiple categories or more conditionals, in 
   case you would like to show it on the frontend then you could add the category
   as a Select field or regular HTML field.
 * To learn more about how mu-plugin works [https://wpmudev.com/blog/wordpress-mu-plugins/](https://wpmudev.com/blog/wordpress-mu-plugins/)
 * > Also is it possible to set it so posts are automatically published.
 * It is, you can change the field setting:
 * [https://monosnap.com/file/mxyNG6PqHLg70CMyP8IQVvfEJPKEbJ](https://monosnap.com/file/mxyNG6PqHLg70CMyP8IQVvfEJPKEbJ)
 * Best Regards
    Patrick Freitas
 *  Plugin Support [Amin – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support2/)
 * (@wpmudev-support2)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/create-post-form-category/#post-15568591)
 * Hello [@beelinedigital](https://wordpress.org/support/users/beelinedigital/) ,
 * We haven’t heard from you for some time now, so it looks like you don’t have 
   more questions for us.
 * Feel free to re-open this ticket if needed.
 * Kind regards
    Kasia

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Create Post Form – Category’ is closed to new replies.

 * ![](https://ps.w.org/forminator/assets/icon-256x256.gif?rev=3443182)
 * [Forminator Forms – Contact Form, Payment Form & Custom Form Builder](https://wordpress.org/plugins/forminator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/forminator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/forminator/)
 * [Active Topics](https://wordpress.org/support/plugin/forminator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/forminator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/forminator/reviews/)

 * 4 replies
 * 4 participants
 * Last reply from: [Amin – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support2/)
 * Last activity: [4 years, 1 month ago](https://wordpress.org/support/topic/create-post-form-category/#post-15568591)
 * Status: resolved