Created
January 23, 2018 00:47
-
-
Save wichaksono/e87d5aaf4db4fbd2b5e411c608bb5e54 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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