Account Settings

Winkelwagen

De winkelwagen is nog leeg

Website Settings

Dondere modus
Hoog contrast
Font grootte
Lees pagina-inhoud
Afdrukken
Realtime
  • Datum: 19-02-2026
  • Week: 08
  • Weer:
  • Seizoen: Winter

Post counter – frontend

Bekijk website

Omschrijving

function gt_get_post_view() {
$count = get_post_meta( get_the_ID(), ‘post_views_count’, true );
return “$count views”;
}
function gt_set_post_view() {
$key = ‘post_views_count’;
$post_id = get_the_ID();
$count = (int) get_post_meta( $post_id, $key, true );
$count++;
update_post_meta( $post_id, $key, $count );
}
function gt_posts_column_views( $columns ) {
$columns[‘post_views’] = ‘Views’;
return $columns;
}
function gt_posts_custom_column_views( $column ) {
if ( $column === ‘post_views’) {
echo gt_get_post_view();
}
}
add_filter( ‘manage_posts_columns’, ‘gt_posts_column_views’ );
add_action( ‘manage_posts_custom_column’, ‘gt_posts_custom_column_views’ )

Single:php

echo number:

Snippet

FieldValue
Snippet Status
Snippet Description
Snippet Type Code
Snippet URL
Snippet Content
Snippet Content CSS
Snippet Content HTML
Snippet Content JS
Snippet Content PHP
Particle Snippet in Software
Particle Snippet in Boilerplate

Relations

ItemType

Pointing items

ItemTypeCategoryTags
Categorie
Tags
URLhttps://gretathemes.com/count-post-views/
TypeSnippet
Time
Price

Geef een reactie

Je e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *

Home