kleine Statistik für WordPress

Hinweis: Dieser Artikel ist älter als zwei Jahre (letzte Änderung: 8. Mai 2020) und evtl. nicht mehr aktuell.

Frank Bueltge zeigt in seinem Artikel "Summe der Beiträge, Seiten, Kategorien, Tags, Kommentare für das WordPress Theme" wie leicht man, ohne Einsatz eines Plugins, eine eigene kleine Statistik für WordPress ausgeben kann. Den dort gezeigten Code brauchst du einfach nur in das gewünschte Template (z. B. sidebar.php) einsetzen.

<?php
/* kleine Statistik */

/* Artikel */
$num_posts = wp_count_posts( 'post' );
$num_posts = $num_posts->publish; //publish, draft
$num_posts = sprintf( __ngettext( '%s Beitrag', '%s Beitr&auml;ge', $num_posts ), number_format_i18n( $num_posts ) );

/*Seiten */
$num_pages = wp_count_posts( 'page' );
$num_pages = $num_pages->publish; //publish
$num_pages = sprintf( __ngettext( '%s Seite', '%s Seiten', $num_pages ), number_format_i18n( $num_pages ) );

/* Kategorien */
$num_cats = wp_count_terms('category');
$num_tags = wp_count_terms('post_tag');

/* Kommentare Möglichkeit 1 */
$num_comm = get_comment_count();
$num_comm = $num_comm['approved']; //approved, awaiting_moderation, spam, total_comments
$num_comm = sprintf( __ngettext( '%s Kommentar', '%s Kommentare', $num_comm ), number_format_i18n( $num_comm ) );

/* Kommentare Möglichkeit 2 */
$num_comm2 = wp_count_comments( );
$num_comm2 = $num_comm2->approved; //approved, moderated, spam, total_comments

/* hier beginnt die Ausgabe */
echo '<ul>';
echo '<li>Beitr&auml;ge: ' . $num_posts . '</li>';
echo '<li>Seiten: ' . $num_pages . '</li>';
echo '<li>Kategorien: ' . $num_cats . '</li>';
echo '<li>Tags: ' . $num_tags . '</li>';
echo '<li>Kommentare: ' . $num_comm . '</li>'; //Möglichkeit 1
echo '<li>Kommentare 2: ' . $num_comm2 . '</li>'; //Möglichkeit 2
echo '</ul>';

/* Ende */
?>
Empfehle uns: email facebook google plus twitter

Artikel Informationen

  • Erstellt am Donnerstag, 25. September 2008 um 19:08 (Letzte Änderungen 8. Mai 2020, 21:43) und abgelegt unter WordPress mit den Tags:
  • Kommentare zu diesen Eintrag im Kommentar Feed Feed.
  • Du kannst einen Kommentar hinterlassen. Pingback ist im Augenblick nicht erlaubt.
Abonnieren
Benachrichtige mich zu:
0 Kommentare
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x