Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select * from (
- SELECT
- if(com.comment_approved = '1' and com.user_id > 0, com_u.display_name, u.display_name) as display_name,
- com.comment_author,
- if(p.post_type = 'reply', t.post_title, p.post_title) as title,
- if(com.comment_approved = '1', com.comment_ID, p.ID) as post_id,
- if(com.comment_approved = '1', com.user_id, p.post_author) as author_id,
- if(com.comment_approved = '1', unix_timestamp(com.comment_date), unix_timestamp(p.post_date)) as post_date,
- if(com.comment_approved = '1', SUBSTRING(com.comment_content, 1, 200), SUBSTRING(p.post_content, 1, 200)) as content,
- if(com.comment_approved = '1', 'comment', p.post_type) as type,
- if(p.post_type = 'reply', ifnull(p.post_parent,0), p.ID) as post_parent,
- max(post_date) as max_post_date
- FROM `wp_posts` as p
- LEFT JOIN `wp_users` as u on u.ID = p.post_author
- LEFT JOIN `wp_posts` as t on t.ID = p.post_parent
- LEFT JOIN `wp_comments` as com on com.comment_post_ID = p.ID
- LEFT JOIN `wp_users` as com_u on com_u.ID = com.user_id
- WHERE ((p.post_type = 'reply' OR p.post_type = 'topic' OR p.post_type = 'post')
- AND p.post_status = 'publish'
- AND p.post_content <> '')
- OR com.comment_approved = '1'
- GROUP BY post_parent)
- ORDER BY max_post_date DESC
- LIMIT 0,12
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement