Kevin
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: HTTP Error 500 after moving to a new serverTheme creator here. I’m certain the issue you’re seeing is due to an old version of PHP. The syntax in this theme requires PHP 5.3+.
I just uploaded a new version of the plugin that adds a
orderby_last_activity
query var. Thanks again for the suggestion!Sorry for the lack of activity here. WordPress doesn’t seem to do a very good job of notifying me of new support requests.
Anyway, great suggestion! I’ll see if I can whip something up and apply a patch. And donations are always appreciated.
Forum: Plugins
In reply to: Sort Posts (in the Loop) by Recent Comments or "Activity"Please direct all questions/comments regarding Filter By Comments to its plugin page.
Forum: Plugins
In reply to: Sort Posts (in the Loop) by Recent Comments or "Activity"I have a plugin submission pending called Filter By Comments, but until it’s approved, I’ve uploaded the plugin to my own site. Let me know if everything works!
Forum: Plugins
In reply to: Sort Posts (in the Loop) by Recent Comments or "Activity"If you’re using a them within a template, they’ll need to go into your functions.php file, but you’ll need to rename the functions (at least
query_vars
) to avoid collision.If you want, I could toss them into a small plugin file that you can include into your project.
Forum: Plugins
In reply to: Sort Posts (in the Loop) by Recent Comments or "Activity"Okay, I just spent the last few hours trying to tackle the same task and found this thread along the way. I figured I’d leave my solution here in case you (or others) haven’t figured something else out.
The function below are methods within my plugin’s class. If you’d prefer to use functions in the global scope, adjust the function names and
add_filter
arguments accordingly.In my constructor:
add_filter('query_vars', array(&$this, 'query_vars')); add_filter('posts_join', array(&$this, 'join_last_comment')); add_filter('posts_orderby', array(&$this, 'orderby_last_comment'));
Methods defined in my class:
function query_vars($vars) { $vars[] = 'orderby_last_comment'; return $vars; } function join_last_comment($sql) { global $wpdb; if(get_query_var('orderby_last_comment')) { $sql .= ' LEFT JOIN (SELECT comment_post_ID AS post, MAX(comment_date) AS date FROM '.$wpdb->comments.' WHERE comment_approved="1" GROUP BY post) AS last_comment ON last_comment.post = '.$wpdb->posts.'.ID '; } return $sql; } function orderby_last_comment($sql) { if(get_query_var('orderby_last_comment')) { return 'last_comment.date DESC'.($sql ? ', '.$sql : ''); } return $sql; }
Usage within
query_posts
,WP_Query
, etc.query_posts('orderby_last_comment=1'); // or query_posts(array('orderby_last_comment' => true));