if condition from post_meta not working in save_post
if condition from post_meta not working in save_post
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);
Sanitize and Save metabox values
I had the same problem and solved it by replacing if( !current_user_can( ‘edit_post’ ) ) return; by: if ( !current_user_can(‘edit_post’, $post_id) ) return;
This issue shouldn’t happen if you’re using the classic editor, however, if you’re using the block/Gutenberg editor which uses the REST API, then that issue can be fixed by using the wp_after_insert_post hook instead. Excerpt from https://make.wordpress.org/core/2020/11/20/new-action-wp_after_insert_post-in-wordpress-5-6/: The new action wp_after_insert_post has been added to WordPress 5.6 to allow theme and plugin developers to run … Read more
Of course it never changes, because you told it that it never changes: // Selected page list const { initialSelectedPages, selectedPagesResolved} = useSelect( ( select) => { …. }, —–>[] <—– ); You declared the dependencies as an empty array, and empty arrays won’t change, so this hook won’t update when your attributes update because … Read more