我有一个不同日期发布的帖子列表
我可以按日期订购邮件
$loop_args = array(
\'post_type\' => \'post\',
\'order_by\' => \'date\',
\'order\' => \'ASC\'
)
如果帖子有评论,我如何按评论日期订购帖子。因此,请按活动对帖子进行排序
我有一个不同日期发布的帖子列表
我可以按日期订购邮件
$loop_args = array(
\'post_type\' => \'post\',
\'order_by\' => \'date\',
\'order\' => \'ASC\'
)
如果帖子有评论,我如何按评论日期订购帖子。因此,请按活动对帖子进行排序
我喜欢中提出的想法this comment. 将posts表连接到comments表似乎是一个超级复杂的SQL(所有SQL对我来说都很复杂)。相反,该链接建议您在帖子中添加一个帖子元字段,以保存最近评论的日期。
add_action(\'comment_unapproved_to_approved\', \'wpa_144482_comment_approved\');
function wpa_144482_comment_approved($comment) {
$comment_post_ID = $comment->comment_post_ID;
$date = $comment->comment_date;
update_post_meta( $comment_post_ID, \'_recent_comment_date\', $date );
}
然后,您应该能够按照_recent_comment_date
领域还有Filter by Comments plugin 但它已经很久没有更新了,所以我不能担保它。
我正在使用主题Twenty12,并修改了文件作者中的标准post查询。php,代码如下:function wpd_author_query( $query ) { //CODE to set $current_user_name here //This gets the author from the URL $author = get_user_by(\'slug\',get_query_var(\'author_name\')); $current_user_name