Show comments from custom post type in wordpress

Show comments from custom post type in wordpress

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

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

One thought on “Show comments from custom post type in wordpress”

Leave a Reply

Your email address will not be published.