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 #1824226
Popular Posts
Closed

Comments

  • Domalis Panagiotis started the conversation

    Hi!


    Is there a way to define the month of the posts that will be inserted as popular posts in the widget? I have posts at my database from 2010 and I don't want them to be included in the Popular Posts Widget. Is there a way to exclude all the posts from previews years and keep only 2018?


    Thanks a lot

  •  2,699
    PenciDesign replied

    Hi,

    Currently, there is no option to do that.

    But, in your case, I think you can display popular posts in weekly or monthly - It can be solve your issues.smile.png


    Best Regards,

    PenciDesign

  • Domalis Panagiotis replied

    Hi!

    I have attached you a screenshot in order to see the settings of the widget and the result at the front-end. Despite the fact that I have set the Display popular posts on: Once Weekly the posts appeared at the front-end are from previews years. Is there any other option or something else that I have to do in order to fix this issue?

    Thanks in advanced

  •  2,699
    PenciDesign replied

    Hi,

    If so, seem your hosting has been disable cron-job for wordpress.

    Let's requirement your hosting to enable cron-job for function wp_schedule_event   from wordpress to make it work.

    We've checked it carefully before - it working fine for most of hosting enable cron-job for function wp_schedule_event.

    After your hosting provide updated it, let's wait a week and you can see the changes ( if you selected to display popular posts by week  )

    Best Regards,

    PenciDesign

  • Domalis Panagiotis replied

    Hi!

    How can I enable cron-job for wordpress function? 

    Thanks

  •  2,699
    PenciDesign replied

    Hi,

    Let's ask your hosting provider about this - because only your hosting provider can allow it for you.

    Let's ask them like I said..

    Best Regards,

    PenciDesign

  • Domalis Panagiotis replied

    Hi!

    WP cron jobs are not disable but do I have to manually create one?

  •  2,699
    PenciDesign replied

    Hi,

    I don't know about this because each hosting has different settings for that.

    But, if your popular posts in one weekly or monthly doesn't clearly data - I'm sure 100% your hosting doesn't support for cron-job for Wordpress to make function: wp_schedule_event doesn't work.

    And with this issues - you need to ask your hosting because it doesn't related with the theme..

    Best Regards,

    PenciDesign

  • Domalis Panagiotis replied

    Ok

    Thanks!

  • Domalis Panagiotis replied

    Hi!

    The problem with the popular posts insists and I am still getting very old posts in the widget. How can I fix this issue? We haven't disable any cron job in wordpress.


    Thanks in advanced


  •  2,699
    PenciDesign replied

    Hi,

    I see that issues before - all other hosting provider also tell doesn't disable crop job for Wordpress, but really, it has been disable. You can see one case here:

    http://prntscr.com/m707g9

    http://prntscr.com/m7084m

    And with all issues related with your hosting, we can't do anything because the theme can't affect anything to the hosting..


    Best Regards,

    PenciDesign

  • Domalis Panagiotis replied

    Hi!

    I have a dedicated server to host this site. I have double checked that the cron job for wordpress is not disable. I tried run the cron job manually but still nothing happened. Is there something else that I can do?

    Thanks

  • Domalis Panagiotis replied

    Please see my screenshot so as to see that the cron jobs are running.


    Thanks

  •  2,699
    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