FatihToprak'daki gibi bir sayaç veya eklenti var mı ? |
12 Mesajlar | 2.254 Okunma |
$count_posts = wp_count_posts();
echo "Toplam Yazı: " .$count_posts->publish. "
";
$comments_count = wp_count_comments();
echo "Toplam Yorum: " . $comments_count->total_comments;
?>
chronocross adlı üyeden alıntı
$count_posts = wp_count_posts();
echo "Toplam Yazı: " .$count_posts->publish. "
";
$comments_count = wp_count_comments();
echo "Toplam Yorum: " . $comments_count->total_comments;
?>
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 Okunma";
}
return $count.' Okunma';
}
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);
}
}
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
setPostViews(get_the_ID());
?>
echo getPostViews(get_the_ID());
?>
if(!function_exists('get_totalviews')) {
function get_totalviews($display = true) {
global $wpdb;
$total_views = $wpdb->get_var("SELECT SUM(meta_value+0) FROM $wpdb->postmeta WHERE meta_key = 'post_views_count'");
if($display) {
echo number_format($total_views);
} else {
return number_format($total_views);
}
}
}
chronocross adlı üyeden alıntı
Dediğim gibi onun için önce okunma sayılarını tutmamız lazım onun için.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 Okunma";
}
return $count.' Okunma';
}
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);
}
}
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
setPostViews(get_the_ID());
?>
echo getPostViews(get_the_ID());
?>
if(!function_exists('get_totalviews')) {
function get_totalviews($display = true) {
global $wpdb;
$total_views = $wpdb->get_var("SELECT SUM(meta_value+0) FROM $wpdb->postmeta WHERE meta_key = 'post_views_count'");
if($display) {
echo number_format($total_views);
} else {
return number_format($total_views);
}
}
}