Sunday, August 14, 2022
HomeWordPress Developmentphp - Why Is Variety of views on wordpress single put up...

php – Why Is Variety of views on wordpress single put up fallacious?


Hi there wordpress devs and neighborhood. I’ve a priority in regards to the variety of views exhibiting on my wordpress posts, its fallacious.

I used this code in features.php;

perform gt_get_post_view() {
    $rely = get_post_meta( get_the_ID(), 'post_views_count', true );
    return "$rely views";
}
perform gt_set_post_view() {
   $key = 'post_views_count';
    $post_id = get_the_ID();
    $rely = (int) get_post_meta( $post_id, $key, true );
    $rely++;
    update_post_meta( $post_id, $key, $rely );
}
perform gt_posts_column_views( $columns ) {
    $columns['post_views'] = 'Views';
    return $columns;
}
perform 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' );

Then within the content-single.php added this above

<?php gt_set_post_view(); ?>

However from my checks the views are fallacious, most occasions once I simply preview a put up to verify its look earlier than publishing am seeing 4 views already.. marvel how potential.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments