I'm having these two WordPress functions:
$wpb_set_post_views = function($postID) {
$count_key = 'wpb_post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
}else{
$count++;
update_post_meta($postID, $count_key, $count);
}
};
add_action( 'wp_head', function ($post_id) {
if ( !is_single() ) return;
if ( empty ( $post_id) ) {
global $post;
$post_id = $post->ID;
}
$wpb_set_post_views($post_id);
});
But the page return Notice: Undefined variable: wpb_set_post_views
for the last line.