SELECT wp_posts.ID FROM wp_posts LEFT JOIN wp_wti_like_post on wp_wti_like_post.post_id=wp_posts.ID WHERE 1=1 AND ( ( post_date_gmt > ’2013-11-16 12:17:03′ ) ) AND wp_posts.post_type = ‘post’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘private’) ORDER BY wp_wti_like_post.value DESC,wp_posts.post_date DESC LIMIT 5, 5
sql语句应该怎样写呢?
//发表文章的同时插入数据到喜欢表
function new_article($post_ID){ global $wpdb; $ip = WtiGetRealIpAddress(); $query = "INSERT INTO {$wpdb->prefix}wti_like_post SET "; $query .= "post_id = '" . $post_ID . "', "; $query .= "value = '0', "; $query .= "date_time = '" . date('Y-m-d H:i:s') . "', "; $query .= "ip = '$ip'"; $success = $wpdb->query($query); if($success){ return $post_ID; }}add_action('publish_post', 'new_article');
把这段代码放到主题function.php里面。 版权声明: 本站资源均来自互联网或会员发布,如果侵犯了您的权益请与我们联系,我们将在24小时内删除!谢谢!