You should hook your actions to the save_post
hook. It fires right after the post is created and the $post_id
and other $post
data variables are already available.
Something like this should do the trick:
add_action( 'save_post', 'jason_code_save_post', 10, 2 );
function jason_code_save_post( $post_ID, $post ) {
if ( 'code' != $post->post_type || wp_is_post_revision( $post_ID ) )
return;
wp_set_object_terms( $post_ID, 'PHP', 'tag' );
}
See Plugin_API/Action_Reference/save_post.
Let me know if something needs more explanation…
Related Posts:
- Custom Post Custom Taxonomy Data Not Saving in Edit Screen
- Custom Taxonomy terms aren’t getting referenced or saved in Quick Edit or Bulk Edit, only on Single product page?
- How to hook save-post function to use taxonomy term in post-slug?
- How to use wp_set_object_terms depending on page ID?
- Advanced search form with filters for custom taxonomies and custom fields
- Combining Multiple Taxonomies in one URL
- Getting the Intersection of Two Custom Taxonomy Terms for a Custom Post Type?
- Why does my custom taxonomy show a total count across all post types
- Custom Taxonomy’s Label to change the text appearing in Appearance > Menu
- Custom post type save_post action not firing
- Why does a custom post type need the ”hierarchical’ args setting?
- Custom Post Type with Nested Taxonomy and Template Files
- Should unaltered default loop/query return a list of custom posts belonging to a custom taxonomy?
- 404 error PageNavi custom type taxonomy | wordpress
- Creating a function that receives the taxonomy terms that have been changed in a custom post type
- Query for posts in 2 taxonomies
- Custom post types – show specific posts
- custom taxonomy archive by year
- Add nonexisting pages to navigation
- Can custom taxonomies items have attached properties?
- Associate custom post types with normal posts
- WP 3.0.5 – Custom posts matching 2 taxonomies
- Custom Post Type Loop within Shortcode
- How can you handle rewrite rules for custom post types with option to filter on custom taxonomy terms?
- How do I make a custom taxonomy for a CPT appear inbetween title and editor boxes?
- Custom Taxonomy URL are redirecting to page with the same name
- Filtering WP_Query Dynamically on the Front-End
- Loop custom taxonomy to get lists of cutom post types?
- Hierarchical Custom Post Types in Array
- Making certain categories of CPT not publicly queryable
- Query with no terms uses index.php template instead of archive.php
- How do I associate a custom post type with another through a taxonomy or storing an ID in a custom field?
- create a subcatagory for a custom post type and out put url as posttype/subcategory/item
- How do I display the taxonomy term alongside the post type post title?
- Get related posts of child term of custom post type
- Filter term taxonomy metabox in custom post type
- Show custom post archive when custom post not specified
- Show custom post type relationships by taxonomy
- Filter CPT posts by one or more categories
- Troubles with acf/save_post and WP_Query
- Custom Post, set object Taxonomy terms in plugin
- Hierarchy and access control for Custom Post Types (CPT)
- Different Category system needed for the Custom Post Type
- single-{post_type}.php not working
- Template to list categories in custom taxonomy
- WordPress wp_query() basic question about args
- How to add current custom taxonomy slug to body class
- Display different information of a custom post type
- How to define a term for custom taxonomy
- Exclude posts with custom taxonomy
- List custom taxonomy as navigation – taxonomy pages with all it’s posts?
- Get parent category(taxonomy) ID from single template of a custom post type
- Dynamic CPT / Taxonomy
- How to approach a site where it has sub-businesses, each with its own pages (“articles”, “staff”)? Don’t want to use WP multisite
- How to rewrite custom taxonomy term archive to use THE SAME SLUG/front as CPT
- How to get the post terms from a child taxonomy
- Get custom term meta problem on single post type
- Creating custom post type posts and associating them with a post from another custom post type
- Custom Post Type View Button in Admin Gives 400 Error
- Custom Taxonomy Filter Issues
- how to organize my categories or should I do custom post types for some?
- How do i display post from a taxonomy term?
- Multiple permalinks for a single post with multiple taxonomies
- rewrite rules hierarchical
- either single-{custom}.php 404’s OR /taxonomy/ 404’s – custom post type and taxonomy permalinks
- Archive page of taxonomy returns a 404 error
- How do I set a post slug automatically based on taxonomy?
- Get a list of custom post type (property) when clicked on custom taxonomy 1 (rent or sale) from custom taxonomy 2 (city) page
- How to divide Subcategories into pages of parent category wordpress
- update custom taxonomy custom fields
- Filter taxonomy by CPT
- How to display “META” array in register_taxonomy
- If ACF Post Object post has custom taxonomy term…
- I want to create a metabox under custom taxonomy
- Customise Permalink Structure For Custom Post Types
- How to filter taxonomy of a custom post type and display it in the single post type page in the back end?
- Parent and child categories with their id in drop_down in CPT
- Custom post type meta fields missing on save_post_type
- CPT/Taxonomy/Postname permalink structure makes pagination break
- Custom Taxonomy not working front side Woocommerce
- Custom post type post_type_link gives “page not found” on any other custom post type
- I want to create an archive and single page for a custom taxonomy for a custom post type
- Taxonomy’s title
- Display all posts from single taxonomy term
- Best way to use Category & Custom Fields?
- Heirarchical URLs with CPT and custom taxonomy
- Displaying taxonomies with manage_{custom-post-type}_posts_custom_column
- Plugin Error on activating
- How to change permalinks to taxonomy and post type’s posts
- Paginate custom taxonomy category with wp_custom_pagination
- Custom post type post taxonomies
- If taxonomy show class of active
- Custom Taxonomy Showing in WP Menu
- Storing/querying custom date data
- Custom Template Taxonomy
- How to relate one custom post type to another custom post type
- Issue On Listing Woocommerce Parent Tag List
- Links in archive not including taxonomy parameter
- Dynamically count the number of custom post types associated to a custom taxonomy
- Taxonomy Archive URL + Template