You don’t need a save_post
hook.
When you call wp_insert_post
, it will return either a post ID or an error object. We can use this to then assign the category by taking categ
from $result
.
I imagine it would looks similar to this:
$post_id = wp_insert_post( $abstract_details );
if ( ! is_wp_error( $post_id ) ) {
wp_set_object_terms( $post_id, $result['categ'], 'category' );
}
You could also use the post_category
parameter of wp_insert_post
or the tax_input
parameter.
Related Posts:
- Posts to expire (deleted) after a date
- Filter categories of posts with checkboxes
- Insert HTML inside link in a walker
- Show category ID on custom post type
- Assign category a default post type
- Navigate posts with different post type that are in the same categories
- Showing custom post type categories in the menu
- How to divide Subcategories into pages of parent category wordpress
- What is the best way to set the post category (Custom Post Type) automatically based on the one of the tags assigned to the post?
- How to sort custom post’s category by id from the theme’s function.php?
- How To Display Category list from Portfolio post type plugin?
- can’t see categories in appearance-menu-categories
- Displaying Custom Post Types In “At A Glance” Meta Box
- Display a query with multiple post types and same relationship on a single page
- Get category id from post id of a custom post type
- WordPress 3.1 – How does one add sticky post capabilities to post types
- Custom-Taxonomy as categories: Remove “most-used” tab?
- White screen error for a custom theme
- Add filter to wp_list_categories and query what type of taxonomy-terms it use?
- Custom user role not working as expected
- Limit Authors to their Own Posts on front-end excluding admins
- List all custom post type posts from a given category?
- Display Posts of a Category in Alphabetical Order (Custom Post Type)
- get custom post type categories
- How to display recent / random posts by its category
- Custom post types and permalink
- Search doesn’t find tags or categories in custom post types
- Querying Term Posts in Loop
- Get Post Primary Category
- How to add custom post types to normal category pages
- Add category attribute to custom shortcode
- wp_insert_post generates endless posts
- Dequeue scripts and styles only for specific custom post type
- Linking to the most recent post in a Custom Post Type
- How to customize a permalink (URL) structure?
- Posts from all the categories are being displayed instead of particular category
- Conditional Statement custom post type category
- Categories sorting
- How can I make my custom posts appear in their assigned category url?
- Allow user to set custom order to a list of custom taxonomies?
- forming WP_Query for posts of all post types but from specific categories
- Can’t edit custom post type
- Limit amount of posts made within a custom taxonomy
- Redirect 404 page with ID in slug to associated page with same ID in slug
- Display featured image from one CPT within another CPT query
- Anon function and add_meta_box
- Post injections into Site Origins Page builder [closed]
- WordPress posts page for customer filtering and sorting along with category filter
- Changing default ‘posts’ parameters with register_post_type_args
- Why is my category template ignoring post type?
- Not sure if I should create multiple custom post type [closed]
- Custom post types and category archive
- Load scripts based on post type
- Redirect to another page using contact form 7? [closed]
- Categorise Custom Post Types
- Tag page only display 10 posts
- Custom post types and ‘new WP_Query’
- Creating Sections for Post Types
- Listing all slugs?
- Custom Ratings for Theme, Proper way to Refactor Code and Clean up Template File
- posts within custom post type all share the same content in the front-end
- Using Wp_Query, Json to add Highcharts series data
- Categories won’t appear on custom post type
- Displaying One Custom Post Type’s Content On Single Post of Another Custom Post Type
- Custom post types category
- Let users upload image(s) to the post from front end
- Page template that uses lightbox to display post images
- Advanced archive url structure (category, tag and date)
- Function to allow single post template based on custom taxonomy?
- Get Posts List of Current Selected Custom Taxonomy in Shortcode
- Custom post category name showing empty
- Custom Form / Search with Custom Post Type Data
- How to show related posts of category on post within custom posttype
- Custom attachment function not working in v5.4.2?
- Sudden 404 pages on product category archives
- Custom Post Types – trying to make “title” display
- Convert category to custom post type
- How can I display a specific category on Front-Page
- subtracting the current post form then whole loop, which is generating all CPT titles
- Custom Function to redirect singular post if specific meta field is empty
- How to seperate posts by categories?
- WooCommerce change
- I can not call the categories of custom post type
- Custom Post Type is not respecting assigned categories
- Help with Travel Guide Setup
- Project Category Heading
- Getting Custom post category from Form
- How can i call a custom method on submission of a custom plugin post type?
- Front end page submission form does not attach custom post type
- Function not pulling image or text from custom post type
- Best way to structure article and issue relationship for CPT
- Custom Post Type used for FAQs Accordion
- Category slug not showing for Custom Post Type
- category page template for custom post type
- Rich Custom Field for Custom Post type not saving
- Custom Post Type Permalinks with %category%
- Return Custom Post Type Categories
- Passing postid of Testimonial Custom Post in Shortcode Parameter
- Is it possible to make is_category() recursive?
- I want to show a list of post with title that have link goes to that post and icon under the specific category to which it belongs