Gibt es einen Hack, mit dem ich die Anzahl der Views der einzelnen Postings im Headlinebereich ausgeben kann?
Ich finde es mühsam immer in den Sats zu gucken welche Postings gut ankommen.
Um schreiben oder kommentieren zu können, benötigen Sie ein Benutzerkonto.
Sie haben schon ein Benutzerkonto? Melden Sie sich hier an.
Jetzt anmeldenHier können Sie ein neues Benutzerkonto erstellen.
Neues Benutzerkonto erstellenGibt es einen Hack, mit dem ich die Anzahl der Views der einzelnen Postings im Headlinebereich ausgeben kann?
Ich finde es mühsam immer in den Sats zu gucken welche Postings gut ankommen.
Hallo!
Wenn du gerade an deiner Website arbeitest oder dein aktuelles Hosting überdenkst: Wir betreiben mit NetzLiving eine Hosting-Plattform, die speziell auf Performance, Sicherheit und einfache Verwaltung ausgelegt ist.
das hängt davon ab, welches Plugin du jetzt nutzt, um die Statistik im Admin zu sehen. Siche rkannst du diese Statiski auch anderso auswerten. Ich nutze dafür: bstat
ich auch! :D
Aber ich möchte die Hits gerne im Kopf des Postings ausgeben,direkt neben der Anzahl der Kommentare usw
na dann:
ich mach das so: ich habe mir eine Seite in den hauptordner geladen ,die mir alle Statistiksachen auflistet. Es ist allerdings egal, wo du den cod einfügst, wenn du das in den Header haben wilst, dann schreibe es einfach in die header.php, an die stelle, wo es später erscheinen soll.
mein beispiel: http://www.bueltge.de/wp-stats.php
in dem fall von bstat-Plugin muss du folgenden code in deinen header integrieren:
<h2>Heute: Populärsten Beiträge</h2>
<ul><?php bstat_todaypop(15, "[*]", "\n"); ?>[/list]
<h2>Populärsten Beiträge</h2>
<ul><?php bstat_recentpop(15, 31, "[*]", "\n"); ?>[/list]
<h2>Gesucht</h2>
<ul><?php bstat_recentrefs(15, 31, "[*]", "\n"); ?>[/list]
Das ist nur ein Beispiel und sollte von dir angemessen formatiert werden. Einarbeiten kann man da noch viel mehr.
zum versuch:
nimm mal folgenden code und speichere ihn als wp-stat.php. (das ist eigentlich das Plugin von Lester "GaMerZ" Chan, welches ich um die funtkionen von bstat erweitert habe) Dann lade ihn in deinen WP-Ordner, Hauptverzeichniss. Habe leider hier keine Möglichkeit gefunden, die Datei anzuhängen, blind-oder gibt es das hier nicht?
dann rufst du die seite mal auf und du wirst sehen, was man alles machen kann.
<?php /*
Template Name: Statistik
*/
/*
* Statistics Plugin For WordPress
* - wp-stats.php
*
* Copyright © 2004-2005 Lester "GaMerZ" Chan
*/
// Require WordPress Header
require('wp-blog-header.php');
// Variables
$comment_author = htmlspecialchars(stripslashes(trim($_GET['author'])));
$page = intval($_GET['page']);
// Get Total Posts
function get_totalposts() {
global $wpdb;
$totalposts = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->posts WHERE post_status = 'publish'");
return $totalposts;
}
// Get Total Comments
function get_totalcomments() {
global $wpdb;
$totalcomments = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = '1'");
return $totalcomments;
}
// Get Total Comments Poster
function get_totalcommentposters() {
global $wpdb;
$totalcommentposters = $wpdb->get_var("SELECT COUNT(DISTINCT comment_author) FROM $wpdb->comments WHERE comment_approved = '1'");
return $totalcommentposters;
}
// Get Total Links
function get_totallinks() {
global $wpdb;
$totallinks = $wpdb->get_var("SELECT COUNT(link_id) FROM $wpdb->links");
return $totallinks;
}
// Get Recent Posts
function get_recentposts($limit = 10) {
global $wpdb, $post;
$recentposts = $wpdb->get_results("SELECT $wpdb->posts.ID, post_title, post_name, post_date, user_nickname FROM $wpdb->posts LEFT JOIN $wpdb->users ON $wpdb->users.ID = $wpdb->posts.post_author WHERE post_date_gmt < '".gmdate("Y-m-d H:i:s")."' AND post_status = 'publish' AND post_password = '' ORDER BY post_date DESC LIMIT $limit");
foreach ($recentposts as $post) {
$post_title = htmlspecialchars(stripslashes($post->post_title));
$post_date = mysql2date('d.m.Y', $post->post_date);
$user_nickname = htmlspecialchars(stripslashes($post->user_nickname));
echo "[*]$post_date - <a href=\"".get_permalink()."\">$post_title</a> ($user_nickname)";
}
}
// Get Recent Comments
function get_recentcomments($limit = 10) {
global $wpdb, $post;
$recentcomments = $wpdb->get_results("SELECT $wpdb->posts.ID, post_title, post_name, comment_author, post_date, comment_date FROM $wpdb->posts INNER JOIN $wpdb->comments ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID WHERE comment_approved = '1' AND post_date_gmt < '".gmdate("Y-m-d H:i:s")."' AND post_status = 'publish' AND post_password = '' ORDER BY comment_date DESC LIMIT $limit");
foreach ($recentcomments as $post) {
$post_title = htmlspecialchars(stripslashes($post->post_title));
$comment_author = htmlspecialchars(stripslashes($post->comment_author));
$comment_date = mysql2date('d.m.Y @ H:i', $post->comment_date);
echo "[*]$comment_date - $comment_author (<a href=\"".get_permalink()."\">$post_title</a>)";
}
}
// Get Top Commented Posts
function get_mostcommented($limit = 10) {
global $wpdb, $post;
$mostcommenteds = $wpdb->get_results("SELECT $wpdb->posts.ID, post_title, post_name, post_date, COUNT($wpdb->comments.comment_post_ID) AS 'comment_total' FROM $wpdb->posts LEFT JOIN $wpdb->comments ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID WHERE comment_approved = '1' AND post_date_gmt < '".gmdate("Y-m-d H:i:s")."' AND post_status = 'publish' AND post_password = '' GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_total DESC LIMIT $limit");
foreach ($mostcommenteds as $post) {
$post_title = htmlspecialchars(stripslashes($post->post_title));
$comment_total = (int) $post->comment_total;
echo "[*]<a href=\"".get_permalink()."\">$post_title</a> - $comment_total comments";
}
}
// Get Comments' Members Stats
// Treshhold = Number Of Posts User Must Have Before It Will Display His Name Out
// 5 = Default Treshhold; -1 = Disable Treshhold
function get_commentmembersstats($threshhold = 5) {
global $wpdb;
$comments = $wpdb->get_results("SELECT comment_author, COUNT(comment_ID) AS 'comment_total' FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_author ORDER BY comment_total DESC");
foreach ($comments as $comment) {
$comment_author = htmlspecialchars(stripslashes($comment->comment_author));
$comment_total = (int) $comment->comment_total;
echo "[*]<a href=\"wp-stats.php?author=$comment_author\">$comment_author</a> ($comment_total)";
// If Total Comments Is Below Threshold
if($comment_total <= $threshhold && $threshhold != -1) {
return;
}
}
}
// Get Links Categories Stats
function get_linkcats() {
global $wpdb;
$linkcats = $wpdb->get_results("SELECT $wpdb->linkcategories.cat_name, COUNT(*) AS 'total_links' FROM $wpdb->links INNER JOIN $wpdb->linkcategories ON $wpdb->linkcategories.cat_id = $wpdb->links.link_category GROUP BY $wpdb->linkcategories.cat_id ORDER BY total_links DESC ");
foreach ($linkcats as $linkcat) {
$cat_name = htmlspecialchars(stripslashes($linkcat->cat_name));
$total_links = intval($linkcat->total_links);
echo "[*]$cat_name ($total_links)\n";
}
}
?>
<?php get_header(); ?>
<div id="content" class="narrowcolumn">
<?php
// If Author Is Not Specified
if(empty($comment_author)) {
?>
<h2>Pulse</h2><?php bstat_pulse($id, 450, 1, 0, 1); ?>
<?php
$before = "<ul>[*][b]";
$after = "[/b][/list]";
$date = date("Y-m-d");
$request = "SELECT SUM(hits_reads) AS note
FROM $bstat_hits_table
WHERE bstat_date = '$date'
";
echo("<h2>Counter heute</h2>" . bstat_reporter($request, $before, $after, 1) . "");
echo("");
$request = "SELECT SUM(hits_reads) AS note FROM $bstat_hits_table
";
echo("<h2>Counter (seit dem 3.Aug 2005)</h2>" . bstat_reporter($request, $before, $after, 1) . "");
?>
<h2>Heute: Populärsten Beiträge</h2>
<ul><?php bstat_todaypop(15, "[*]", "\n"); ?>[/list]
<h2>Populärsten Beiträge</h2>
<ul><?php bstat_recentpop(15, 31, "[*]", "\n"); ?>[/list]
<h2>Gesucht</h2>
<ul><?php bstat_recentrefs(15, 31, "[*]", "\n"); ?>[/list]
<h2 class="pagetitle">Allgemeine Statistik</h2>
<ul>
[*][b]<?=get_totalposts()?>[/b] Beitraege
[*][b]<?=get_totalcomments()?>[/b] Kommentare
[*][b]<?=get_totalcommentposters()?>[/b] unterschiedliche Einschnitte in den Kommentaren
[*][b]<?=get_totallinks()?>[/b] Links
[/list]
<h2 class="pagetitle">10 letzten Beiträge</h2>
<ul><?php get_recentposts(); ?>[/list]
<h2 class="pagetitle">10 letzten Kommentare</h2>
<ul><?php get_recentcomments(); ?>[/list]
<h2 class="pagetitle">10 meisten Beitraege mit Kommentaren</h2>
<ul><?php get_mostcommented(); ?>[/list]
<h2 class="pagetitle">Kommentaruser</h2>
[list=1]<?php get_commentmembersstats(); ?>[/list]
<h2 class="pagetitle">Kategorien</h2>
<ul><?php list_cats(1,'All','name','asc','',true,0,1,0,1,true,0,0,0,'','','',true); ?>[/list]
<h2 class="pagetitle">Linkkategorien</h2>
<ul><?php get_linkcats(); ?>[/list]
<?php
// Displaying Comments Posted By User
} else {
// Number Of Comments Per Page
$perpage = 10;
// Comment Author Link
$comment_author_link = urlencode($comment_author);
// Total Comments Posted By User
$totalcomments = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_author='$comment_author'");
// Checking $page and $offset
if (empty($page) || $page == 0) { $page = 1; }
if (empty($offset)) { $offset = 0; }
// Determin $offset
$offset = ($page-1) * $perpage;
// Some Comments Stats
if(($offset + $perpage) > $totalcomments) { $maxonpage = $totalcomments ; } else { $maxonpage = ($offset+$perpage); }
if (($offset + 1) > ($totalcomments)) { $displayonpage = $totalcomments ; } else { $displayonpage = ($offset+1); }
// Count Total Pages
$totalpages = ceil($totalcomments/$perpage);
// Getting The Comments
$gmz_comments = $wpdb->get_results("SELECT $wpdb->posts.ID, comment_author, comment_date, comment_content, ID, comment_ID, post_date, post_title, post_name FROM $wpdb->comments INNER JOIN $wpdb->posts ON $wpdb->comments.comment_post_ID = $wpdb->posts.ID WHERE comment_author = '$comment_author' AND comment_approved = '1' AND post_date_gmt < '".gmdate("Y-m-d H:i:s")."' AND post_status = 'publish' ORDER BY comment_post_ID DESC, comment_date DESC LIMIT $offset, $perpage");
?>
<h2 class="pagetitle">Comments Posted By <?=$comment_author?></h2>
Displaying [b]<?=$displayonpage?>[/b] To [b]<?=$maxonpage?>[/b] Of [b]<?=$totalcomments?>[/b] Comments</p>
<?php
foreach($gmz_comments as $post) {
$comment_id = intval($post-> comment_ID);
$comment_author2 = htmlspecialchars(stripslashes($post->comment_author));
$comment_date = mysql2date('d.m.Y @ H:i', $post->comment_date);
$comment_content = wpautop(stripslashes($post->comment_content));
$post_date = mysql2date('d.m.Y @ H:i', $post->post_date);
$post_title = htmlspecialchars(stripslashes($post->post_title));
// If New Title, Print It Out
if($post_title != $cache_post_title) {
echo "
[b]<a href=\"".get_permalink()."\" title=\"Posted On $post_date\">$post_title</a>[/b]</p>";
}
echo "<blockquote>$comment_content <a href=\"".get_permalink()."#comment-$comment_id\">Comment</a> Posted By [b]$comment_author2[/b] On $comment_date</blockquote>";
$cache_post_title = $post_title;
}
?>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td align="left" width="50%">
<?php
if($page > 1 && ((($page*$perpage)-($perpage-1)) < $totalcomments))
echo '
[b]«[/b] [url="wp-stats.php?author='.$comment_author_link.'&page='.($page-1).'"]Previous Page[/url]</p>';
else
echo '
</p>';
?>
</td>
<td align="right" width="50%">
<?php
if($page >= 1 && ((($page*$perpage)+1) < $totalcomments))
echo '
[url="wp-stats.php?author='.$comment_author_link.'&page='.($page+1).'"]Next page[/url] [b]»[/b]</p>';
else
echo '
</p>';
?>
</td>
</tr>
<tr>
<td colspan="2" align="center">
Pages (<?=$totalpages?>) :
<?php
if ($page >= 4) {
echo "<a href=\"wp-stats.php?author=$comment_author_link\">« First</a> ... ";
}
if($page > 1) {
echo " <a href=\"wp-stats.php?author=$comment_author_link&page=".($page-1)."\">«</a> ";
}
for($i = $page - 2 ; $i <= $page +2; $i++) {
if ($i >= 1 && $i <= $totalpages) {
if($i == $page) {
echo "[$i]";
} else {
echo "<a href=\"wp-stats.php?author=$comment_author_link&page=$i\">$i</a> ";
}
}
}
if($page < $totalpages) {
echo " <a href=\"wp-stats.php?author=$comment_author_link&page=".($page+1)."\">»</a> ";
}
if (($page+2) < $totalpages) {
echo " ... <a href=\"wp-stats.php?author=$comment_author_link&page=$totalpages\">Last »</a>";
}
?>
</p>
</td>
</tr>
</table>
[b]««[/b] [url="wp-stats.php"]Back To Stats Page[/url]</p>
<?php
} // End If
?>
</div>
<?php
get_sidebar();
get_footer();
?>
Alles anzeigen
Viel Spass und Gruss Frank
Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!