php - Display comments from the most recent to the oldest in wordpress -
i try of comments of wordpress database related post, have decided have enabled , display them in page, recent oldest. these comments custom field subfields. there way this?
i've written below code in wordpress site now:
$texts = get_post_meta($post->id, "texts", true); if( $texts ) { for( $i = 0; $i < $texts; $i++ ) { $comment_text = get_post_meta( $post->id, 'texts_' . $i . '_comment_text', true ); $comment_displayed = get_post_meta( $post->id, 'texts_' . $i . '_comment_displayed', true); if ($comment_text && $comment_displayed) { $user = get_post_meta( $post->id, 'texts_' . $i . '_user', true ); $user = getuserbyid($user); $text_date = get_post_meta($post->id, 'texts_' . $i . '_text_date', true ); echo $user->display_name; echo html_entity_decode($comment_text); echo $text_date; } } }
check if works ?
function reverse_comments($comments,$id) { $comments = array_reverse($comments); return $comments; } add_filter('comments_array','reverse_comments',10,2);
Comments
Post a Comment