How to create separate comment section for all the virtual pages?

Is this even possible? Do I have to create separate table to store the comments and do all the work myself or is there any alternative for that?

If I have to create separate table, is there a way to use default wordpress functions in any way?


I haven't probably grasped the concept of custom post type yet or don't understand their power properly. Let me give you an example.

Say I have 2 database table. wp_product_category and wp_product. Each product will have a product_category. There are few products_category and thousands of products.

It's not possible to create all the pages manually. So, I have rewritten the URL and all the request is handled by a single page product. When someone goes to product/product-category/ or product/product-category/product-name, the page is created comparing the values of query_var and making the content and title from the plugin.

I don't understand how custom post type can be used in this case. Any direction would be great help.

  • what's a virtual page?
    – birgire
    Jan 18, 2014 at 10:03
  • @birgire A page that isn't an actual wordpress page/post. Rather it's generated by URL rewriting and other hooks.
    – sakibmoon
    Jan 18, 2014 at 10:50
  • What about embedding external comments to your virtual pages, like facebook or disqus ? Or try to create a hidden post (or some other custom post type) for each of your virtual pages, with wp_insert_post() so you can use the default WordPress commenting system
    – birgire
    Jan 18, 2014 at 11:19
  • @birgire I don't understand what do you mean by embedding. These pages does not have any existence in the database. There will be thousands of pages divided into category and I am not sure how to assign each custom post type to each virtual page. If you can explain more, that will be a great help.
    – sakibmoon
    Jan 18, 2014 at 13:21
  • Is your data existing (as in database tables already in place, etc) or do you plan to organize it that way? In WordPress context it would make sense to create product as custom post type and product_category as custom taxonomy for it.
    – Rarst
    Jan 18, 2014 at 13:46

1 Answer 1


WordPress comments are segmented by IDs of their parent posts.

For virtual pages you would either have to:

  • replicate the process (by creating underlying Custom Post Type for it)
  • or completely rebuild how it's handled for them (for example by tracking segments as comment meta and query accordingly)
  • There will be thousands of virtual pages under different category. I am not sure, how custom post type can handle that situation. If you can give me any example, that would be better.
    – sakibmoon
    Jan 18, 2014 at 13:11
  • Comment meta seems to be a nice suggestion. I understand how to do that. Can you suggest which hooks will be better to handle the situation? And if you think custom post type will be better to do this, please explain a little more about it. Thanks a lot. You have opened a new door for me.
    – sakibmoon
    Jan 18, 2014 at 13:17
  • @sakibmoon either way would be rather involved, comments are old concept and hadn't been made as much more generic as custom post types and taxonomies. If you have thousands of those pages I would questions why isn't custom post type used for them in first place.
    – Rarst
    Jan 18, 2014 at 13:28
  • Please see my edit. Sorry for the long edit. But I hope it will help you to give me a better direction.
    – sakibmoon
    Jan 18, 2014 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.