tandow
Forum Replies Created
-
Forum: Plugins
In reply to: [Post Views Counter] How to get most viewed posts of specific time periodIt seems like outputting only post/product IDs is not possible since PVC expects all
wp_posts
table columns to be selected in the SQL query.Moreover, it seems like WooCommerce’s
wc_get_products
function can be used together with PVC’s query variables like this:$output = wc_get_products( array( 'type' => array('simple'), 'status' => 'publish', 'return' => 'objects', // Required by PVC. 'fields' => 'all', 'suppress_filters' => false, 'orderby' => 'post_views', 'views_query' => array( 'after' => '2 weeks ago' ) ) );
Setting
'return' => 'objects'
outputs an array with product objects.Setting
'return' => 'ids'
doesn’t output IDs but an array with post objects.Please feel free to comment if I am doing something wrong here.
Forum: Plugins
In reply to: [Post Views Counter] How to get most viewed posts of specific time periodI looked through the source code of the plugin and it seems like a time period for the
pvc_get_most_viewed_posts
function can be specified by using the following query argument:'views_query' => array( 'year' => '', 'month' => '', 'week' => '', 'day' => '', 'after' => '', // can be string or array 'before' => '', // can be string or array }
By using
after
andbefore
, it is possible to define a custom time period. The strtotime() function is applied to them when value is a string, i.e. if I want the views from the past 2 weeks:'views_query' => array( 'after' => '2 weeks ago' )
See
includes/class-query.php
file for more details.After going through the woocommerce code a bit (trying to understand what the
notices/error.php
file expects), I’ve rewritten the line above to the following:'outbid_message' => wc_get_template_html( "notices/error.php", array( 'notices' => array( array( 'notice' => __("You have been overbidded!", 'ultimate-woocommerce-auction'), 'data' => '', ), ), )),
PHP warning message is gone now. But not sure if it really works like this. I am also not really sure what to set the
data
key to, hence, I set it to an empty string for now.I’d appreciate it, if you could verify the possible solution and then rework your code since my change in your code would get overwritten on the next update. Thank you!