Can you describe what you’re trying to achieve a bit more?
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.
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 . "'"
);
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.