Need to tweak this function
-
Someone else wrote this function which displays the “most viewed” on my site, but it doesn’t have an end date. So if an article from 2 years ago is my most viewed it’s still in there.
To remove items as the got old, I created a category called “older” and I want items that I put in that category to disappear from the list.
I tried to add something like
AND category <> 'older'
or
AND post_category <> 'older'
but that doesn’t work. Can you help? Thanks!
Original code (from functions.php) below…
function wow_get_most_viewed($limit = 5) { global $wpdb; $where = "post_type = 'post'"; $output = ''; $most_viewed = $wpdb->get_results("SELECT DISTINCT $wpdb->posts.*, (meta_value+0) AS views FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON $wpdb->postmeta.post_id = $wpdb->posts.ID WHERE post_date < '".current_time('mysql')."' AND $where AND post_status = 'publish' AND meta_key = 'views' AND post_password = '' ORDER BY views DESC LIMIT $limit");
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Need to tweak this function’ is closed to new replies.