how to increase custom post value by one most efficiently?
Enter WP_Post and the “magic” getter – did you know… $value = get_post_meta( $post->ID, ‘custom_field’, true ); …is the same as $value = $post->custom_field; So you can shorten your code to: update_post_meta( $post->ID, ‘custom_field’, $post->custom_field + 1 ); Note you cannot do $post->custom_field++ – since the property doesn’t actually exist, it can’t be modified. Read … Read more