ID, "ab_postview_views", true); if(!isset($current_views) OR empty($current_views) OR !is_numeric($current_views) ) { $current_views = 0; if (get_option('ab-post-radio')==1) { $content .= "Read count: ".$current_views; } } else { if (get_option('ab-post-radio')==1) { $content .= "Read count: ".$current_views; } } return $content; } } function abpost_add_view() { global $post; $current_views = get_post_meta($post->ID, "ab_postview_views", true); if(!isset($current_views) OR empty($current_views) OR !is_numeric($current_views) ) { $current_views = 0; } $new_views = $current_views + 1; update_post_meta($post->ID, "ab_postview_views", $new_views); return $new_views; } //Post counter in all post // ADD NEW COLUMN function ABPostCount_columns_head($defaults) { $defaults['abpost_view_counter'] = 'Post View Counter'; return $defaults; } // SHOW THE POST COUNTER function ABPostCount_columns_content($column_name, $post_ID) { global $post; if ($column_name == 'abpost_view_counter') { $current_views = get_post_meta($post->ID, "ab_postview_views", true); if($current_views =="") {$current_views=0;} echo $current_views; } } //end post counter function abpostview_settings() { add_settings_section("section", "Settings", null, "abpvc"); add_settings_field("ab-post-radio", "Show counter after post?", "abpostview_radio_display", "abpvc", "section"); register_setting("section", "ab-post-radio"); } function abpostview_radio_display() { ?> >Yes >No