WordPress tutorial, Show comments from custom post type in wordpress. we shows comments in sidebar. But what to do for show comments for custom post type.

Show comments from custom post type in wordpress

It’s not well documented, but according to the codex, you can pass a ‘post_type’ variable in the get_comments function.

<?php
 $comments = get_comments('number=10&status=approve&post_type=YOUR_POST_TYPE');
foreach($comments as $comment) :

// comment loop code will go here

endforeach;
?>

Note: This code only useful after wordpress 3.1 version.

Show comments from custom post type in wordpress

Show comments from custom post type in wordpress

Written by Purab Kharat

I Purab am from Pune. I worked as WordPress and Drupal Architect and consultant. I worked on many technologies like Wordpress, Drupal, Ruby on Rails, Flex, PHP, jQuery etc... Senior Technical Lead at Smartsourcing Global Pvt Ltd in Princeton, NJ, USA.I contributor of many wordpress plugins and Drupal Modules. I am core developer of Drupal.Connect to purab on LinkedIn or Follow @purab on Twitter or Follow me on Google+ or Write Mail to purabdk@gmail.com or Chat with me on Skype : purabdk

This article has 1 comment

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>