I checked and it works with this:
$new_post = array(
'post_content' => $_POST['post-content'],
'post_title' => wp_strip_all_tags( $_POST['post-title'] ),
'post_type' => 'custom_pt'
);
note: I used a text input for the single category
<input id="input-name-value" name="input-name-value" type="text" />
I havent tried it with a select – option dropdown. or more than 1 category.
$post_id = wp_insert_post( $new_post );
wp_set_object_terms( $post_id, $_POST['input-name-value'], 'yourCategory' );
It would be nice if someone could pimp this out in order to get full functionallity.
Thanks.
Related Posts:
- WP insert post and custom taxonomy
- Not Able to Insert Taxonomy Term Using wp_insert_post()
- How I upload, save and set a featured image from my frontend?
- Trying to save custom post type from frontend partially working
- front end radio custom taxonomy with custom post type
- wp_insert_post custom taxonomy
- WordPress tax_input only if logged in
- Programmatically adding posts
- wp_set_object_terms() not adding new term to custom post and custom taxonomy
- How to save custom taxonomy from front end post submission
- How to checked selected category checkbox when my custom post inserted from frontend
- How to make front end form only accept certain values
- Why cant I add a custom post type to a custom taxonomy?
- Add term for custom taxonomy from front end
- How do I find out which (page) template file my custom child post is looking for?
- wp_insert_post deleting previous post custom meta
- Change custom post taxonomy values from front-end
- Saving Child Terms on front end not setting parent
- Add a meta to custom post type which corresponds to a particular taxonomy
- Add a image to a post published on a CPT from the front-end
- Extensive search filtering and results->PDF in the front-end
- install.php Custom Taxonomy Term not being added to custom post
- How to Add Custom Taxonomy To Woocommerce Plugin
- How to get the posts of a custom taxonomy term
- How can I rewrite URLs to pass taxonomy and post type values to the query?
- wp_set_object_terms() is not replacing term, but creating a new one
- Custom Post Type Permalink For Parent/Child, 404 Page Not Found Error
- List custom post types in dropdown
- remove support for ‘Categories’ for a custom post type
- Categories under custom post types doesn’t show properly
- Hide child term posts on parent term pages
- List all posts in Custom Post Type but group dynamically by Custom Taxonomies
- Taxonomy-{taxnonomy}.php is not working
- Auto Draft Specific Categories Posts after a certain number of Days
- Custom Taxonomy 404
- How to add custom fields to admin UI and REST API response?
- Custom Post Type: Linking Terms to show Count
- How to filter the taxonomy terms based on another taxonomy term
- How to sync tags between posts that are linked through Posts 2 Posts?
- Custom Post Type with two hierarchical Custom Taxonomies: strategy to generate best permalink structure
- Combining custom post type and post category
- how can i get posts from custom post type particular taxonomy category
- Conditionally custom post type url rewrite
- get_the_terms return only last term
- How do I get array of types associated with a taxonomy?
- Root slug of taxonomy returning 404
- Pagination for Custom Taxonomy Page [duplicate]
- get_category_parents for custom post type taxonomy
- Hide post navigation if current post is in a category with only one post
- Setting up taxonomy to relate various custom post types – advice on structuring?
- I want to change the word “Tags” in WordPress to something else, but how?
- What is the best practice for displaying my plugin content in themes?
- Set post terms for multiple posts
- Get terms that contain posts that in turn belong to other terms?
- Archive for a Taxonomy of a Custom Post type
- Custom Taxonomy Is Being Pulled into a Page, But It Doesn’t Have A Hyperlink
- Querying two taxonomies with tax_query not woking
- Shared terms between taxonomies
- custom hierarchical taxonomy and custom post type list contains surplus posts
- How to handle this specific case of custom post type?
- Show category and tag link as a submenu under custom post type submenu
- Urls in Custom Post Type work for Terms but not for its Taxonomies
- Display custom meta on page that has been check in custom post type
- Add filter to Admin list for all custom post types by their custom taxonomies
- Single.php for Custom Post Type > Taxonomy > Term
- Add the custom post term to the custom post title
- Display 3 recent posts from one taxonomy
- Displaying custom taxonomy menu in custom post type archive
- Custom post types templates
- prevent sub categories to show up
- Custom post type and multi taxonomies + customize url
- Archive page URL for custom taxonomy and post type
- Custom Post Type Archive Page showing as 404
- Custom taxonomy terms hierarchical navigation
- Is it possible to add the Gutenberg block editor to a custom taxonomy?
- What is the best way to structure posts for the same event happening in different years?
- WordPress Custom Taxonomy – If not parent term
- Dynamically Adding Posts of Post Type to A List
- Multiple Custom Post Type in Taxonomy Archive Causing White Screen
- Adding a Section for Visitors
- Why is my loop not populating the page with my custom taxonomy terms from my custom post type?
- Show parent category and subcategory once in while loop
- I cannot display custom posts in custom taxonomy
- How to change URL structure for custom post type in wordpress? Custom taxonomy + custom Post name [duplicate]
- Custom taxonomy with custom post type template not showing
- Loop to display parent categories in custom taxonomy
- One-Time Script TimeOut for Large Data
- CPT Efficient way to display posts from different categories with custom query
- Associate custom categories to different user IDs
- How to create default taxonomy term for a custom post type? [duplicate]
- redirect old post type url to new structure url
- archive-{custom_post_type}.php not getting recognized wordpress
- How to retrieve the permalink for a specific (custom) term?
- Values inside a custom field to determine which category posts to display
- title tag for custom post type remove taxonomy name from title tag
- Create a page selector using taxonomies
- Advanced search form with filters for custom taxonomies and custom fields
- Code to show related posts (custom post type and custom taxonomy/category) is messing with other code
- register_term_meta not working
- Dynamically count the number of custom post types associated to a custom taxonomy