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
- How to automatically update ACF field value every year?
- Generate Post Title From ACF Fields on Custom Post Type
- How to get a custom type post data when it has a connection with another custom type post?
- Custom post type showing same Post on all Pages
- Why would social icon badges disappear after adding a custom post type?
- Custom Post Type Metadata Not Saving
- Sort a custom post with ACF: Date Picker & Display Featured!
- detect when a custom post is cretaed for the first time
- ACF repeater field usage
- List of users that clicked a ‘Join’ button at single post
- Post loop count is not in order
- What do the numbers mean at the end of add_action(‘save_post’)…?
- How to inherit field value from parent post into in child / sub post
- How can I add a shortcode to query Custom Post Type with ACF in WordPress?
- 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?
- How check if a post is saved from backend or frontend?
- set_query_params using custom params defined in functions file?
- 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
- ACF for custom post type archive pages: which hook to use?
- How to define the template for custom posts?
- Batch Extract Date from post title and put into ACF custom field
- Query entries from custom post type in an ACF flexible content field
- Why is wp api returning old acf values?
- How to use single.php for creating, reading and editing Custom Posts with ACF
- Distribute Custom Post in different pages
- get custom post type value in header.php [closed]
- posttype and custom fields on multisite
- How do I get_the_postID() for a custom post that uses ACF repeater field?
- How do I replace the post title with a custom field?
- Advanced custom fields Post Object image field not displaying in custom post type single.php
- Sum and count of custom field values
- How do I show a link or ‘Read More’ button on a custom field excerpt when it is less than the word limit
- How to export custom post type with ACF to individual file with automation?
- Custom fields not showing in custom post type
- Group by custom field value (start and end times)
- Custom post types, disable fields
- meta query not retrieving posts
- Custom Post Type with Configurable Sidebar via ACF
- Get A Custom Field From A Custom Taxonomy Of A Custom Post Type [closed]
- Custom Sidebar in Editor (not Widget) for Custom Post Type in Genesis
- ACF Relationship Posts how to show additional content
- wp-includes does not contain a feed template
- Using WP meta query to show custom post types by a start and finish date
- Limit search field to just search a custom post type with custom fields
- Advanced custom field – posted fields from custom post type
- How to prevent meta data from being edited in a post?
- Catch and display error on save_post action
- Excerpt length: get first paragraph
- SQL query – get ids – Advanced Custom Fields / WPeC
- Custom field with Types: get custom field’s value label (of type select)
- Custom Post Type Meta Box Text Input Field Won’t Save When Blank
- How to display author details in a custom post type in the wordpress backend?
- Show posts associated with ACF post object and custom post type
- Show/hide posts and categories based on user meta
- 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?
- How can i show ACF in post excerpts
- ACF – Retrieve custom taxonomy from a relationship field
- How to set a ‘page’ as parent of a custom post type?
- Custom front-end form for adding post – Category problem
- Set up a WP Cron scheduled event to update calculated ACF field
- Query filter by value in meta_value array
- Show Post Revisions on front-end
- count & sum the value of custom field of the author post in dynamic posts
- How to show Custom Post Type – Case Study using Shortcode & ACF
- Add custom post related by custom field to custom post
- Create if else for post types in WP_Query ‘post__in’ values
- Create loop from selected terms in ACF taxonomy field
- Sort custom posts by date and then by taxonomy
- Grouping custom wordpress post types by acf value
- Set Post Private if no linked Post Objects (ACF)
- Show in an entry a Custom Post Type associated to a post
- Orderby custom fields is not working
- Custom post ID & display information related to this ID
- Using ACF values in nested WP queries for CPT with date values in the past
- Create/populate Custom Posts ACF fields from external JSON file
- Expire post to draft by date-picker custom field
- WordPress URL rewrites using Advanced Custom Field
- Custom Post Type and Structure Question
- Display a Custom Post Type with Advanced Custom Fields on Homepage
- CPT email notification including only new value custom fields
- Filter result of Custom Post Type using meta_query with ACF
- Save post action is called twice
- How to display posts with plugin (advanced custom fields) field groups?
- WordPress – display relationship between blog posts and custom posts
- Same custom post type with different ACF
- Query posts by current ACF meta key value on single page as related posts
- Custom sorting in post columns by ACF Pro Select Field
- Load info from customposttype into template page
- Show custom post type event if current day using ACF
- Display Custom Field or Custom Taxonomy in front page /post/product
- Why do my custom post types stop displaying over time?
- Urgent – WordPress keeps creating posts