-
#htmlcaption2 #htmlcaption2 #htmlcaption2 #htmlcaption2 #htmlcaption2
PAKET WEBSITE

WEB BLOG

DOMAIN.COM/.NET/.ORG/. CO DLL
HOSTINGGOOGLE HOSTED (FREE)
RESPONSIVEYA
LAYOUTBLOG
SUPPORT24 JAM

Rp. 800.000

Lihat Detail

PORTAL BERITA

DOMAIN.COM/.NET/.ORG/. CO DLL
HOSTINGGOOGLE HOSTED (FREE)
RESPONSIVEYA
LAYOUTWEB PORTAL
SUPPORT24 JAM

Rp. 1.200.000

Lihat Detail

COMPANY PROFILE

DOMAIN.COM/.NET/.ORG/. CO DLL
HOSTINGGOOGLE HOSTED (FREE)
RESPONSIVEYA
LAYOUTCOMPANY PROFILE
SUPPORT24 JAM

Rp. 2.500.000

Lihat Detail

Video

Cara menampilkan Pageview di setiap artikel di wordpress tanpa plugin

Ditulis Oleh : Admin

Pada Tanggal : 2 Jul 2014

Idwebdesain - Oke kali ini idwebdesain akan posting tentang Cara membuat Pageview di setiap artikel, tetapi ini bukan untuk blogger atau blgspot melainkan untuk wordpress, kita tau bahwa di wordpress banyak sekali plugin yang bisa kita manfaatkan seperti fasilitas Pageview di setiap artikel ini, namun saya akan menoba bereksperimen dengan tidak menggunakan plugin tersebut dan tentu bisa kamu terapkan di blog wordpress kamu.

untuk pluginnya bisanya saya menggunakan plugin count per day namun kali ini langsung saja menggunakan kode yang kita pasang di functions.php, oke untuk lebih jelasnya simak tulisan berikut ini :

Login ke dashboard wordpress
pilih menu Appearance > Editor
Pilih file functions.php
kemudian tambahkan kode ini :
function getPostViews($postID){
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
return "0 View";}
return $count.' Kali';
}
function setPostViews($postID) {
$count_key = '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);}
}
Kemudian Klik Update file
Berikutnya pilih file index.php
Copy code ini :
<?php setPostViews(get_the_ID()); ?>
Letakkan Kode diatas di bawah kode :
 <?php while ( have_posts() ) : the_post(); ?>
Nah untuk menampilkan Total pageviewnya tempatkan kode ini di atas atau di bawah kode
<?php the_content(); ?>
atau jika menggunakan auto readmore :
<!--?php if (is_single()) { the_content(); } else { the_excerpt(); } ?-->
Kode pageview :
Telah Dibaca : <!--?php echo getPostViews(get_the_ID()); ?-->
Silahkan ganti teks warna merah dengan bahasa yang di inginkan
dan Selamat mencobaa....


Tidak ada komentar:

Berikan Komentar Anda