Guest User

Untitled

a guest
Oct 20th, 2015
74
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. select
  2.   if(cm.comment_approved = '1' and cm.user_id > 0, cm_u.display_name, ps_u.display_name) as display_name,
  3.   cm.comment_author,
  4.   a.title as title,
  5.   if(cm.comment_approved = '1', cm.comment_ID, pst.ID) as post_id,
  6.   if(cm.comment_approved = '1', cm.user_id, pst.post_author) as author_id,
  7.   a.max_post_date as post_date,
  8.   if(cm.comment_approved = '1', SUBSTRING(cm.comment_content, 1, 200), SUBSTRING(pst.post_content, 1, 200)) as content,
  9.   if(cm.comment_approved = '1', 'comment', pst.post_type) as type,
  10.   if(pst.post_type = 'reply', ifnull(pst.post_parent,0), pst.ID) as post_parent
  11. from (
  12. SELECT
  13.         if(p.post_type = 'reply', t.post_title, p.post_title) as title,
  14.  
  15.         if(com.comment_approved = '1', unix_timestamp(com.comment_date), unix_timestamp(p.post_date)) as post_date,
  16.         if(p.post_type = 'reply', ifnull(p.post_parent,0), p.ID) as post_parent,
  17.         max(if(com.comment_approved = '1', unix_timestamp(com.comment_date), unix_timestamp(p.post_date))) as max_post_date,
  18.         max(if(com.comment_approved = '1', com.comment_ID, p.ID)) as max_post_id
  19. FROM `wp_posts` as p
  20. LEFT JOIN `wp_posts` as t on t.ID = p.post_parent
  21. LEFT JOIN `wp_comments` as com on com.comment_post_ID = p.ID
  22. WHERE ((p.post_type = 'reply' OR p.post_type = 'topic' OR p.post_type = 'post')
  23.         AND p.post_status = 'publish'
  24.         AND p.post_content <> '')
  25.         OR com.comment_approved = '1'
  26. group by post_parent) a
  27. LEFT JOIN `wp_posts` as pst on a.max_post_id = pst.id
  28. LEFT JOIN `wp_comments` as cm on a.max_post_id = cm.comment_post_ID
  29. LEFT JOIN `wp_users` as cm_u on cm_u.ID = cm.user_id
  30. LEFT JOIN `wp_users` as ps_u on ps_u.ID = pst.post_author
  31. order by max_post_date desc
  32. limit 0,12
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×