Join the Soledad Facebook Users Group here
for Share, assistance, discussion, and Updates related to Soledad WordPress Theme.

If you can't create a new ticket - you can send us an email via our contact form and we will get back to you.

Okay
  Public Ticket #2879708
penci post views count
Closed

Comments

  • isidore_clem started the conversation

    Hello, 

    The numbers stay the same on year / month / week / all
    I need it to be accurate - I don't want to edit it. 

    My theme version is 6.6.1
    and I have the same issues on both my websites. 

    Thank you for your help


  •   PenciDesign replied privately
  •   isidore_clem replied privately
  •  2,578
    PenciDesign replied

    Hi,

    The post count will not work correctly when you using the cache plugin. I've fixed this issue by going to Appearance → Customize → Single Posts: check to Enable ajax Post View Count option.

    Regards,
    PenciDesign.


  • isidore_clem replied

    Hello, 

    Unfortunatly, this is a new week today and still the same number on every line - I checked old posts and recent posts. What makes you believe It was solved ? Maybe we have a misunderstanding ? 


    Thank you for your help

  •  2,578
    PenciDesign replied

    Hi,

    Please wait for me to check your site settings and update this ticket when I'm done.

    Regards,
    PenciDesign.


  • isidore_clem replied

    Hello, 

    Did you find a solution ? 

    Thank you for your help

  •  2,578
    PenciDesign replied

    Hi,

    We currently check this issue and update your site soon.

    Regards,
    PenciDesign.

  • isidore_clem replied

    Hello, 


    Still no news ? We wait for almost two months.. 

    Regards

  •  2,699
    PenciDesign replied

    Hi,

    We've checked it and I see your post views on each month/week/yeah won't reset because your hosting doesn't support cron job for function wp_schedule_event from WordPress

    Here is the function we're using to clear views data after each month/week/yeah on pennews/inc/extras.php:

    /**
     * Add schedules intervals
     *
     * @since  2.5.1
     *
     * @param  array $schedules
     *
     * @return array
     */
    add_filter('cron_schedules', 'penci_add_schedules_intervals');
    if (!function_exists('penci_add_schedules_intervals')) {
        function penci_add_schedules_intervals($schedules)
        {
            $schedules['weekly'] = array(
                'interval' => 604800,
                'display'  => __('Weekly', 'pennews')
            );
            $schedules['monthly'] = array(
                'interval' => 2635200,
                'display'  => __('Monthly', 'pennews')
            );
            
            $schedules['yearly'] = array(
                'interval' => 31536000,
                'display'  => __('Yearly', 'pennews')
            );
            return $schedules;
        }
    }
    /**
     * Add scheduled event during theme activation
     *
     * @since  2.5.1
     * @return void
     */
    // add_action('after_switch_theme', 'penci_add_schedule_events');
    add_action('init', 'penci_add_schedule_events');
    if (!function_exists('penci_add_schedule_events')) {
        function penci_add_schedule_events()
        {
            if ( ! get_option('penci_flag_cron')) {
                update_option('penci_flag_cron', 1);
                if (!wp_next_scheduled('penci_reset_track_data_weekly')) {
                    wp_schedule_event(time(), 'weekly', 'penci_reset_track_data_weekly');
                }
                if (!wp_next_scheduled('penci_reset_track_data_monthly')) {
                    wp_schedule_event(time(), 'monthly', 'penci_reset_track_data_monthly');
                }
                if (!wp_next_scheduled('penci_reset_track_data_yearly')) {
                    wp_schedule_event(time(), 'yearly', 'penci_reset_track_data_yearly');
                }
            }
        }
    }
    /**
     * Remove scheduled events when theme deactived
     *
     * @since  2.5.1
     * @return void
     */
    add_action('switch_theme', 'penci_remove_schedule_events');
    if (!function_exists('penci_remove_schedule_events')) {
        function penci_remove_schedule_events()
        {
            wp_clear_scheduled_hook('penci_reset_track_data_weekly');
            wp_clear_scheduled_hook('penci_reset_track_data_monthly');
            wp_clear_scheduled_hook('penci_reset_track_data_yearly');
        }
    }
    add_action('penci_reset_track_data_weekly', 'penci_reset_week_view');
    if (!function_exists('penci_reset_week_view')) {
        function penci_reset_week_view()
        {
               penci_cron_reset_view('_count-views_week');
        }
    }
    add_action('penci_reset_track_data_monthly', 'penci_reset_month_view');
    if (!function_exists('penci_reset_month_view')) {
        function penci_reset_month_view()
        {
            penci_cron_reset_view('_count-views_month');
        }
    }
    add_action('penci_reset_track_data_yearly', 'penci_reset_year_view');
    if (!function_exists('penci_reset_year_view')) {
        function penci_reset_year_view()
        {
            penci_cron_reset_view('_count-views_year');
        }
    }
    if ( ! function_exists('penci_cron_reset_view')) {
        function penci_cron_reset_view($meta_key) {
            global $wpdb;
            $wpdb->query($wpdb->prepare("UPDATE $wpdb->postmeta SET meta_value = '0' WHERE meta_key = %s", $meta_key));
        }
    }

    We've checked and it still works fine on my testing sever, so I'm sure 100% this function doesn't support by your hosting - let's contact and ask them about this. You can copy my reply and send it to them to check it.


    Best Regards,

    PenciDesign

  • isidore_clem replied


  •  2,578
    PenciDesign replied

    Hi @isidore_clem,

    Any problem with your site?

    Regards,
    PenciDesign.


  •   isidore_clem replied privately
  •  2,578
    PenciDesign replied

    Hi,

    About your issue, please install the Missed Scheduled Posts Publisher by WPBeginner plugin here: https://wordpress.org/plugins/missed-scheduled-posts-publisher/

    But if you want the post view working exactly, please convert the WP Cron-job to Server Cron-job by following the instruction here: https://www.siteground.com/tutorials/wordpress/real-cron-job/

    Regards,
    PenciDesign.


  • isidore_clem replied

    Hi, 


    I installed the missed scheduled posts. If I convert the wp cron job to a server cron job, all the other plugins which use the wp cron will stop functionning ! I would be a shame to broke several plugins beacause of one, don't yout think ? 


    I hope the missed scheduled post will do the job


  •  2,578
    PenciDesign replied

    Hi,

    Are you config your server cronjob? You need to set up your server after installing the Missed Scheduled Posts Publisher to make all cronjob work correctly.

    Let read this article & following the instruction correctly: https://www.siteground.com/tutorials/wordpress/real-cron-job/

    Regards,
    PenciDesign.


  • isidore_clem replied

    Hello, 


    Maybe my english is not good enough to make me understand. 

    I don't want to  define('DISABLE_WP_CRON', true); because it's working fine with other plugins and services. 

    You need to make your plugin work without breaking the other one, please. 


    Thank you for your help,

  •  2,578
    PenciDesign replied

    Hi,

    The PenNews theme doesn't have any similar issue with the Cronjob like to your site, so there are no options to change/improve here, the problem from your server/hosting doesn't work properly with the WP Cronjob.

    All the plugins will be working properly when you convert WP Cronjob to Server Cronjob. Please read the link I've replied to you in the previous reply.

    Regards,
    PenciDesign.