Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/**
* sedikit Modifikasi :D
* @see http://www.edikomputer.com/2013/03/cara-membuat-pageview-di-setiap-artikel.html
* untuk menngetahui berapa kali sebuah artikel dibaca
*/
function the_post_count($post_id = '')
{
$postid = $post_id;
if ($post_id == '') {
global $post;
$postid = $post->ID;
}
$post_count = get_post_meta($postid, 'post_count_view', true);
/**
* jika berada di halaman single atau artikel full
* harus diberi get_the_ID()
*
* ex : <?php the_post_count(get_the_ID()); ?>
**/
if (is_single() && $post_id != '') {
if ($post_count == '') {
$post_count = 1;
} else {
$post_count++;
}
update_post_meta($postid, 'post_count_view', $post_count);
}
echo ($post_count != '') ? $post_count : 0;
}
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.