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
- How to get the proper category in permalink with custom post type assigned to multiple categories
- Auto Generate Post Title from 2 ACF Taxonomies [closed]
- How to detect filter in URL in Category page?
- Set menu active state for custom posttype and category, given custom taxonomy term
- How to show CPTs in term archive
- How to change post featured image using a custom field of category?
- wp_insert_post generates endless posts
- Remove standard meta boxes from custom taxonomy
- CPT Archive with core Category
- Group posts by custom post type
- What’s the difference between same wp functions get_posts(); functions in different form?
- I did group my search results by post type, but how can i give each of them its own order?
- Display all posts in main category and 1 subcategory
- Replace li Items with divs with classes
- Dequeue scripts and styles only for specific custom post type
- showing custom post types of a certain category only
- Function to display custom post type on front page makes menu items dissapear
- Get posts from a custom post type by child categories of a parent category
- custom post type not showing in menu
- Linking to the most recent post in a Custom Post Type
- Custom Post Type Archive Page Filtering
- Getting posts under the custom post type ui category
- How can I auto-assign a CPT post to category in a custom taxonomy when published?
- How to customize a permalink (URL) structure?
- get_posts() with custom post type does not work outside page.php
- Posts from all the categories are being displayed instead of particular category
- Get parent categories of custom post type
- Custom Post Type with Templates using Meta Boxes?
- Can I list a custom post type within another custom post type in the admin area?
- How to query_post custom posts within default taxonomy?
- Conditional Statement custom post type category
- Change custom post type slug from plugin options
- Show custom post type filtered by category
- Custom Post Type With Categories
- Display posts from Custom Post Type in category page on front-end
- Categories sorting
- How can I make my custom posts appear in their assigned category url?
- How to call in Custom Post-Type Categories?
- Allow user to set custom order to a list of custom taxonomies?
- get_category_parents for custom post type taxonomy
- Separate custom categories from default category
- forming WP_Query for posts of all post types but from specific categories
- wp_list_categories() – current-cat class also inside posts?
- Showing posts from different categories and from custom post type
- Can’t edit custom post type
- Custom post type getting wrong categories and tags
- Categories of custom taxonomy don’t show any posts
- How to display custom taxonomies with links in filter menu?
- Show a Category X’s custom post type on Category X archive page?
- Set URL link to featured image of custom post type
- Change CPT archive title
- AJAX load more for different custom post type loops
- On update or create post redirect to current post position in list
- I need to add endpoint for wordpress categories
- Multiple level category drop-down from the WordPress dashboard
- Cannot add category or custom taxonomy from admin. WordPress site is hosted in Windows 16 server via IIS. No XAMPP or WAMP
- Add custom post type settings to wordress default posts
- How to target a specific custom post type post and its all children and grandchildren?
- Featured image overlay when changing post status
- Hide parent categories when clicked, and show it’s childs
- Limit amount of posts made within a custom taxonomy
- Problem with displaying posts in the CPT category
- get_post_meta not working on publishing
- Filter CPT posts by one or more categories
- Getting categories of posts under a custom taxonomy
- Redirect 404 page with ID in slug to associated page with same ID in slug
- WordPress wrapped added a span tag to every single p tag
- ACF field key/value to show on taxonomy list
- Custom Post Types with a common category for a blog listing
- Re-registering a custom post type not working (not showing up)
- Display featured image from one CPT within another CPT query
- Query taxonomy of taxonomy of custom post type
- Can’t remove front from permalinks for custom taxonomy category page
- How to get categories linked in posts for a specific post type
- Best way to style first post differently?
- How to make custom posts types display when published for the future
- Custom post type, organized by categories
- How to display “Category and Post_tag” component in a CPT Gutenberg edit screen?
- How to rewrite url for any specific taxonomy?
- Remove CPT name from permalink but add %category% instead
- create a new page from a custom post type similar to an authors page
- Set a checkmark in a category based on a URL-parameter
- CPT archive admin menu label
- Anon function and add_meta_box
- WP Query with categories only shows one post and ignores the category
- Adding custom post type to count in category
- How to edit this code to get the categories in achieve page?
- Category with post type pagination returns 404