• Hello.

    I noticed your plugin collect views by total, year, month, week and day in the database, so I need to get views by of all that time ranges. I tried to find the right line to get the views data but I failed.

    This is a Worpress Popular Posts code which I need help to modify in order to get your views right, or a similar function, please!!!

    /* Storing views of different time periods as meta keys */
    add_action( 'wpp_post_update_views', 'custom_wpp_update_postviews' );
    
    function custom_wpp_update_postviews($postid) {
    
    	if ( function_exists('wpp_get_views') ) {
    		
    update_post_meta( $postid, 'views_total', wpp_get_views( $postid, 'all', false ) );
    update_post_meta( $postid, 'views_daily', wpp_get_views( $postid, 'daily' ) );
    update_post_meta( $postid, 'views_weekly', wpp_get_views( $postid, 'weekly' ) );
    update_post_meta( $postid, 'views_monthly', wpp_get_views( $postid, 'monthly ) );
    	}
    }
    • This topic was modified 5 years, 10 months ago by vicetias.
    • This topic was modified 5 years, 10 months ago by vicetias.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter vicetias

    (@vicetias)

    Ok, just found the right code and worked, but I can’t get views from day, week, month, year, just total. If I add ‘day’ into pvc_get_post_views doesn’t work.

    if ( !function_exists( 'PostViews' ) ) {
        function PostViews( $postID ) {
    
            // Get views count
            $count = pvc_get_post_views( $post_id );
    
            // Views meta key
            $count_key = 'post_views';
    
            // Save / update post meta
            update_post_meta( $postID, $count_key, $count );
    
        }
    }
    Plugin Author dFactory

    (@dfactory)

    Sure it possible and here’s the full exaplantion: https://dfactory.eu/support/topic/get-by-date-interval/

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Collect views in post meta keys’ is closed to new replies.