Skip to content

Instantly share code, notes, and snippets.

@mrkkr
Created February 8, 2019 11:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrkkr/a92f4a1a757e299f101a15e51986a209 to your computer and use it in GitHub Desktop.
Save mrkkr/a92f4a1a757e299f101a15e51986a209 to your computer and use it in GitHub Desktop.
Wordpress - display comments form selected post
<?php
$args = array('cat' => 'home','post_type' => 'post'));
$post_obj = new WP_Query($args);
while($post_obj->have_posts() ) : $post_obj->the_post();
//display comments
$comments = get_comments(array(
'post_id' => $post->ID,
'number' => '2' ));
foreach($comments as $comment) {
//format comments
}
endwhile;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment