PenciDesign replied
Hi,
Have you tried deactivate all plugins and check it again?
After deactivate all plugins, change the display popular posts to once week or once month and try it again. ( Make sure you clearly all the cache )
If it work, let's enable each plugin to check what's plugin caused this issue.
Here is the code we've used for process cron-job from functions.php file:
/**
* 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', 'soledad' )
);
$schedules['monthly'] = array(
'interval' => 2635200,
'display' => __( 'Monthly', 'soledad' )
);
return $schedules;
}
}
/**
* Add scheduled event during theme activation
*
* @since 2.5.1
* @return void
*/
add_action( 'after_switch_theme', 'penci_add_schedule_events' );
if ( ! function_exists( 'penci_add_schedule_events' ) ) {
function penci_add_schedule_events() {
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' );}
}
}
/**
* 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' );
}
}
/**
* Reset view counter of week
*
* @since 2.5.1
* @return void
*/
add_action( 'penci_reset_track_data_weekly', 'penci_reset_week_view' );
if ( ! function_exists( 'penci_reset_week_view' ) ) {
function penci_reset_week_view() {
global $wpdb;
$meta_key = 'penci_post_week_views_count';
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->postmeta SET meta_value = '0' WHERE meta_key = %s", $meta_key ) );
}
}
/**
* Reset view counter of month
*
* @since 2.5.1
* @return void
*/
add_action( 'penci_reset_track_data_monthly', 'penci_reset_month_view' );
if ( ! function_exists( 'penci_reset_month_view' ) ) {
function penci_reset_month_view() {
global $wpdb;
$meta_key = 'penci_post_month_views_count';
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->postmeta SET meta_value = '0' WHERE meta_key = %s", $meta_key ) );
}
}
We've tested this feature carefully on some hosting and I can confirm you this function working fine without any issues.
If the hosting doesn't support for make functions:
wp_next_scheduled
and
wp_clear_scheduled_hook
Your popular posts will can't be update data.. That make it doesn't work..
Best Regards,
PenciDesign