You can not use is_single() conditional tag here.
You can check the type of post in the function this way:
add_action( 'save_post', 'set_genre_on_save', 20, 3 );
function set_genre_on_save( $post_id, $post, $update ) {
if ($post->post_type != 'hvm')
return;
// ...
}
You can also attach the function to the action hook save_post_{post_type}, which is triggered only for the {post_type}
type. Then there is no need to check the type of post inside the function.
add_action( 'save_post_hvm', 'set_genre_on_save', 20, 3 );
Related Posts:
- Custom Taxonomy terms aren’t getting referenced or saved in Quick Edit or Bulk Edit, only on Single product page?
- Troubles with acf/save_post and WP_Query
- save_post affect creation and deletion
- Function that get ACF fields value before saving
- Using save_post to replace the post’s title
- Prevent post from being published if custom fields not filled
- importing third party json feed as custom post type [closed]
- how to get posts by custom post type then display Custom fields?
- Submitting posts from the front end – sanitizing data
- WP Rest API Querying Custom Posts by ACF fields
- Custom field values get deleted
- Meta Query “IN” doesn’t work with ACF checkbox filter
- Change 2 fields in the post depending on the 3rd field before save
- Insert slider (Custom Post Type) into pages
- get terms that have post with custom post type between 2 values
- How to set custom post type as post title to avoid ‘Auto Draft’
- Query current and future events, ordered by begin date
- Change message given when deleting post from custom post type
- Building an Advanced Search (text, tags, category, custom fields) – Getting the wrong SQL query
- Linking three taxonomies with ACF
- update_post_meta() whenever custom post type is updated
- Frontend posting – everything saves other than checkboxes?
- Query Custom Post Types by date (custom field) range
- Remove duplicated values from a loop
- How to retrieve category NAME instead of ID in a function with a taxonomy custom field?
- “add_post_type_support” with Custom Post Type & ACF
- Custom Post type and Custom Field WP_Query
- Display multiple custom post types and sort them chronological by one of their fields
- Confusion regarding Nonce & using it in Custom Columns for Saving Checkbox Value to Post Meta
- get_posts of Custom Post Type AND Custom Taxonomy
- the_content() not outputting anything (Advanced Custom Fields)
- How to add a post slug to a url?
- ACF Field on CPT Slug
- Custom Post Type + ACF and performance [closed]
- Meta Query Not Returning Output Despite Having Matching Values
- Retrieve custom field from Contact Form 7 [closed]
- The loop seems stuck to a single (now deleted) post
- CPT Validation to not show “Post updated.”
- Multiple Frontend Filters Using Advanced Custom Fields
- Displaying custom field according to date
- save_post custom post type ? $_POST not working?
- How to set the seo title tag on a page by page basis?
- How to add/edit advanced custom fields on custom post type’s WordPress REST API?
- Sort a custom post with ACF: Date Picker & Display Featured!
- Custom Post Type page sorts differently on different environments
- Postname on unique permalink structure appends “-2” for a custom post type. How can I get this to stop happening?
- Custome fields not displayed
- How to detect that the save_post hook is calling the callback associated to the current edit post page only
- Create short URL with auto 301 redirect
- Why is wp api returning old acf values?
- get custom post type value in header.php [closed]
- How do I get_the_postID() for a custom post that uses ACF repeater field?
- Group by custom field value (start and end times)
- Custom post types, disable fields
- wp-includes does not contain a feed template
- Excerpt length: get first paragraph
- Fetch data from two custom post types and create multidimensional array for output to html table
- Having a repeating custom field in admin custom post type, what I’d go better with, for DB’s sake? ACF repeater or query a different post type?
- Query filter by value in meta_value array
- count & sum the value of custom field of the author post in dynamic posts
- Orderby custom fields is not working
- Custom post ID & display information related to this ID
- Expire post to draft by date-picker custom field
- Display a Custom Post Type with Advanced Custom Fields on Homepage
- Filter result of Custom Post Type using meta_query with ACF
- Same custom post type with different ACF
- Custom sorting in post columns by ACF Pro Select Field
- WP_Query not using custom taxonomy categories on custom post type
- How would i insert a value of custom field from Advaced Custom Field into shortcode generated by Gravity Forms [closed]
- Auto generate excerpt from ACF field on a CPT that does not support excerpt or content
- Subpages URLs for Custom Post Type
- Custom post type not pulling CSS
- Button link display in shortcodes using custom field in ACF
- How do I link to a dynamic ACF button from a Custom Post type?
- How to hide sub fields in a field group and also the entire field group if the answer selected is “no”
- Create 3 Levels of relations with WordPress
- How to stop post status from reverting to Published?
- Linking posts together with Advanced Custom Fields “both ways”
- How can I save a Custom Post Title and Slug with a Custom Field?
- Custom permalink rewrite rules – how do I fix this?
- Custom Field as Custom Post type element class
- Extracting Post ID and passing through as an attribute in a shortcode
- Automatically convert standard posts with custom fields to custom post types
- Submit and edit font end custom post type
- How to implement custom post type’s users
- How to make a custom search template for custom taxonomy?
- Making my custom column sortable
- Get month and day from a Date Picker custom field
- Modifying and Displaying URL’s in a Post Template using parse_url
- Custom post type adding additional markup
- Advanced Custom Fields: query posts filtered by multiple field values
- WooCommerce – Complete Order when an action occurs
- WordPress Loop trouble with ACF [closed]
- Filter page ID outside the loop and order
- Elementor Custom Query to get Posts by ACF (Post Object Field
- Custom taxonomy meta fields
- Create WP multisites as a custom post type
- WordPress WP_Query Sort by 2 dates – custom fields
- Custom Sort Order for Custom Post Type Taxonomy
- WordPress post objects in one parent post object