Skip to content

Instantly share code, notes, and snippets.

@twentyfortysix
Created February 15, 2021 23:22
Show Gist options
  • Save twentyfortysix/2f29ab8d85eb81f3a5a46fdcaa66963f to your computer and use it in GitHub Desktop.
Save twentyfortysix/2f29ab8d85eb81f3a5a46fdcaa66963f to your computer and use it in GitHub Desktop.
php, enclosure, timber, comments
<?php
$args = array(
'status' => 'approve',
'number' => 30,
'order' => 'DESC'
);
$comments = get_comments($args);
$post_ids = array_map(function($key, $value) {
return $value->comment_post_ID;
}, array_keys($comments), $comments);
$pargs = [
'post_type' => 'post',
'post__in' => array_unique($post_ids),
];
$data['posts'] = Timber::get_posts($pargs);
Timber::render('comments-archive.twig', $data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment