How do I set a custom post type Category after import using wp_set_post_terms
The answer is don’t use wp_set_post_terms, use wp_set_object_terms instead. wp_set_post_terms only works with the built-in post object.
The answer is don’t use wp_set_post_terms, use wp_set_object_terms instead. wp_set_post_terms only works with the built-in post object.
Your code calls get_the_category() but it doesn’t use the value returned. // … if ( isset( $_POST[‘img-destacada’] ) ) { $categories = get_the_category($post_id); $img = ”; // $categories should contain either an array of WP_Term objects, // or an empty array. if ( ! empty( $categories ) ) { // Here I’ve used the slug … Read more
How to use wp_set_object_terms depending on page ID?
Use save_post to generate file on wordpress
if condition from post_meta not working in save_post
acf/save_post affecting WP_Query results
Through trial and error I was able to get this working reliably without further hooks or using JavaScript in the Editor. After restoring the hook, I added clean_post_cache($post_id); Separately, I updated the order of priority (from 10 to 5) for the original action. The code in the original question has been updated to reflect this.
Taxonomy Child Not Updating Unless I Click Update Twice
get_post_meta() returns nothing in save_post, publish_post, wp_after_insert_post
I you need to use update_post_meta($post_id,’your_meta_key’,’your_meta_value’); or you can save in new variable like $city_value = $_POST[‘city_field’]; then code will be update_post_meta($post_id,’city_field’,$city_value);