Skip to content
Public Ticket #17828

Post Views in Backend

Conversation thread

DerekAMG replied

Customer Reply

Boom! That's fixed it, thank you so much yet again. 

Derek

PenciDesign Supporter replied

Staff Reply

Hi,

Please go to Appearance → Customize → Additional CSS then add the following custom CSS code:

.author-socials .fa {
    font-family: "FontAwesome";
}
Clear your site & browser cache then check again.

Regards,
PenciDesign.

DerekAMG replied

Customer Reply

Thank you, that is superb. First class support as always.

One more question I have is why do my social icons show up as corrupted in my author bios. Facebook, Instagram and LinkedIn are all showing up as a jumble of four letters instead.

PenciDesign Supporter replied

Staff Reply

Hi,

Please modify the PHP code like this:

if ( is_admin() && current_user_can( 'manage_options' ) ) {
    add_filter( 'manage_edit-post_columns', 'derekamg_view_columns' );
    add_action( 'manage_posts_custom_column', 'derekamg_show_view_columns' );
} function derekamg_view_columns( $columns ) {
    $columns['views'] = 'Views';
    return $columns;
} function derekamg_show_view_columns( $name ) {
    global $post;
    switch ( $name ) {
        case 'views':
            $all_times_views = get_post_meta( $post->ID, '_count-views_all', true );
            $week_views = get_post_meta( $post->ID, '_count-views_week', true );
            $month_views = get_post_meta( $post->ID, '_count-views_month', true );
            $month_views = $month_views ? $month_views : 0;
            $week_views = $week_views ? $week_views : 0;
            $all_times_views = $all_times_views ? $all_times_views : 0;
            echo 'All time views: <strong>' . $all_times_views . '</strong><br/>';
            echo 'Week views: <strong>' . $week_views . '</strong><br/>';
            echo 'Month time views: <strong>' . $month_views . '</strong>';
            break;
    }
}

Regards,
PenciDesign.


DerekAMG replied

Customer Reply

Really happy with the way this is working but wondered if there was a simple way to restrict the post views data to administrators only? Currently my contributors can see it also. Ideally I'd like them not to be able to.

DerekAMG replied

Customer Reply

Thank you, yes that works great now. Really appreciate your help. I don't want the view showing always because we lockdown some stories to encourage more subscribers, but then their view stats are lower.

Thank you. Great support!

PenciDesign Supporter replied

Staff Reply

Hi,

The post view function doesn't work because you've disabled it on the Customize options.

I've enabled it by going to Appearance → Customize → General: Enable ajax Post View Count.

If you don't want to show the post view on the front-end, please go to Appearance → Customize → Additional CSS, add the following custom CSS code:

.entry-meta-item.penci-post-countview.penci_post-meta_item {
    display: none;
}

Regards,
PenciDesign.


PenciDesign Supporter replied

Staff Reply

Hi,

Please send me your site login credential in a PRIVATE reply. I'll need to log in & check your config.

Regards,
PenciDesign.


DerekAMG replied

Customer Reply

That still doesn't seem to be showing views – just 0s across the board even when I have clicked through certain posts. Strange. 

PenciDesign Supporter replied

Staff Reply

Hi,

If the previous doesn't show post view, please try to replace it with this code:

add_filter( 'manage_edit-post_columns', 'derekamg_view_columns' );
function derekamg_view_columns( $columns ) {
    $columns['views'] = 'Views';
    return $columns;
}
add_action( 'manage_posts_custom_column', 'derekamg_show_view_columns' );
function derekamg_show_view_columns( $name ) {
    global $post;
    switch ( $name ) {
        case 'views':
            $all_times_views = get_post_meta( $post->ID, '_count-views_all', true );
            $week_views = get_post_meta( $post->ID, '_count-views_week', true );
            $month_views = get_post_meta( $post->ID, '_count-views_month', true );
            $month_views = $month_views ? $month_views : 0;
            $week_views = $week_views ? $week_views : 0;
            $all_times_views = $all_times_views ? $all_times_views : 0;
            echo 'All time views: <strong>' . $all_times_views . '</strong><br/>';
            echo 'Week views: <strong>' . $week_views . '</strong><br/>';
            echo 'Month time views: <strong>' . $month_views . '</strong>';
            break;
    }
}

Regards,
PenciDesign.


DerekAMG replied

Customer Reply

Can I just check that code is correct? It's definitely showing the column with all views, weekly and monthly in the posts page (excellent) but all seem to be stuck on 0. Even though we've had views. Not sure the counter is drawing correctly. 

Derek

PenciDesign Supporter replied

Staff Reply

Hi,

Please install the Code Snippet plugin, then create a new snippet with the following content:

add_filter( 'manage_edit-post_columns', 'derekamg_view_columns' );
function derekamg_view_columns( $columns ) {
    $columns['views'] = 'Views';
    return $columns;
} add_action( 'manage_posts_custom_column', 'derekamg_show_view_columns' );
function derekamg_show_view_columns( $name ) {
    global $post;
    switch ( $name ) {
        case 'views':
            $all_times_views = get_post_meta( $post->ID, 'penci_post_views_count', true );
            $week_views = get_post_meta( $post->ID, 'penci_post_week_views_count', true );
            $month_views = get_post_meta( $post->ID, 'penci_post_month_views_count', true );             $month_views = $month_views ? $month_views : 0;
            $week_views = $week_views ? $week_views : 0;
            $all_times_views = $all_times_views ? $all_times_views : 0;             echo 'All time views: <strong>' . $all_times_views . '</strong><br/>';
            echo 'Week views: <strong>' . $week_views . '</strong><br/>';
            echo 'Month time views: <strong>' . $month_views . '</strong>';
            break;
    }
}

Regards,
PenciDesign.


DerekAMG started the conversation

Conversation Start

Hi there, 
I'm trying to find a way to show the total post views in the backend of the site for each story. I don't want them on the articles as it sets them all to 0 when I do that and some are locked into the paywall so have fewer views. I want to be able to see the post views for each story in the backend in a column on the posts page. Or at least in the post views panel we see if we un-tick: Hide Post Views.
I'm sure I'm not the only one who would find this very helpful.

Thanks Derek

Want to join this conversation or access attachments? Sign in first.