Title: Display Recent Comment One Time
Last modified: September 1, 2016

---

# Display Recent Comment One Time

 *  Resolved [v123shine](https://wordpress.org/support/users/v123shine/)
 * (@v123shine)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/display-recent-post-one-time/)
 * Good day,
 * I’m using this code for display top **10 recent comments** from custom post type“**
   book**“.
 *     ```
       <ul>
       	<?php
       		$args = array(
       			'post_type' => 'ask',
       			'number' 	=> '10',
       			'orderby'	=> 'date',
       			'order' 	=> 'DESC'
       		);
       	$comments = get_comments( $args );
       	foreach($comments as $bw_comment): ?>
       		<li><a href="<?php echo get_permalink($bw_comment->comment_post_ID); ?>"><?php echo get_the_title($bw_comment->comment_post_ID); ?></a></li>
       	<?php endforeach;?>
       </ul>
       ```
   
 * Everything work fine. But the problem is, if one post have so many replied. And
   top 10 recent comments can contains only one post. This is very bad for visual.
 * Screenshot: [https://s32.postimg.org/5sc7i45p1/same.jpg](https://s32.postimg.org/5sc7i45p1/same.jpg)
 * Is that possible 1 post only display once in recent post??
 * Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [v123shine](https://wordpress.org/support/users/v123shine/)
 * (@v123shine)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/display-recent-post-one-time/#post-7605499)
 * **Update**: This is the right question.
 * Is that possible 1 post only display once in recent comment??
 *  [cedcommerce](https://wordpress.org/support/users/cedcommerce/)
 * (@cedcommerce)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/display-recent-post-one-time/#post-7605507)
 * Hello v123shine,
    Please add this code in your theme functions.php file
 *     ```
       $args = array(
         'post_type'       =>  'ask',
         'number'  => '10',
         'orderby' => 'date',
         'order'  => 'DESC'
       );
       $comments = get_comments( $args );
       $post_comment = array();
       foreach($comments as $bw_comment):
        if (!in_array($bw_comment -> comment_post_ID, $post_comment)):
         ?><li><a href="<?php echo get_permalink($bw_comment->comment_post_ID); ?>"><?php echo get_the_title($bw_comment->comment_post_ID); ?></a></li><?php
         $post_comment[] = $bw_comment -> comment_post_ID;
        endif;
       endforeach;
       ```
   
 * This code will display 1 post only display once in recent comment.
    Hope it will
   help you . Thanks
 *  Thread Starter [v123shine](https://wordpress.org/support/users/v123shine/)
 * (@v123shine)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/display-recent-post-one-time/#post-7605521)
 * Dear Cedcommerce, thank you… thank you very much for your kindly help 🙂

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Display Recent Comment One Time’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [v123shine](https://wordpress.org/support/users/v123shine/)
 * Last activity: [9 years, 9 months ago](https://wordpress.org/support/topic/display-recent-post-one-time/#post-7605521)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
