Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author dFactory

    (@dfactory)

    Can you describe what you’re trying to achieve a bit more?

    Thread Starter sroskylos

    (@sroskylo1)

    I am trying to display the total views of a product, post in one field and an one other field the total views of the product, post.

    Plugin Author dFactory

    (@dfactory)

    PVC does not support for a date query in pvc_post_views or pvc_get_post_views functions currently but this is a good idea to have that.

    For now you can use a direct query or create a custom function that does that:

    global $wpdb;
    
    $post_id = get_the_ID(); // post id
    $today = date( 'Ymd' ); // today's date
    
    $post_views = (int) $wpdb->get_var( "
    	SELECT SUM(count) AS views
    	FROM " . $wpdb->prefix . "post_views
    	WHERE id IN (" . $post_id . ") AND type = 0 AND period = '" . $today . "'"
    );
    Thread Starter sroskylos

    (@sroskylo1)

    Thank you!

    Thread Starter sroskylos

    (@sroskylo1)

    How can i make this

    global $wpdb;
    
    $post_id = get_the_ID(); // post id
    $today = date( 'Ymd' ); // today's date
    
    $post_views = (int) $wpdb->get_var( "
    	SELECT SUM(count) AS views
    	FROM " . $wpdb->prefix . "post_views
    	WHERE id IN (" . $post_id . ") AND type = 0 AND period = '" . $today . "'"
    );

    to [today-views] in shortcode?

    Can you help me with the function?

    • This reply was modified 9 years, 1 month ago by sroskylos.
Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Today views?’ is closed to new replies.