I have written a plugin that creates it's own tables to house the necessary schema for client's product. Then I created a single page that retrieves the custom object via passed in query string like so:


Where it would retrieve the item with ID 7 in it's custom table.

However the client would like to have commenting enabled on their custom object's page, with those comments obviously being related to the item with id 7.

Seeings how I don't create a page, or post for this object. Is there any way to tie Wordpress Built In Commenting to this custom object ?

  • 1
    While I wouldn't say it's impossible outright, endeavors like this usually drown in massive amounts of edge cases. Natively comments are engineered to go with post types. – Rarst Oct 17 '13 at 20:39

I would enable comments for that page and save them with a comment meta holding your object's ID. To be more specific, this is how would I tackle this issue:

  1. Hook into comment_post action and save a comment meta called my_object_id with your custom object ID as a value when posting a comment from the relevant page.
  2. To display only relevant comments, I'd query the comments with meta_key => "my_object_id" and meta_value set to the actual object ID you're retrieving the comments for.
| improve this answer | |
  • Nice solution. WP has some phenomenal power with the hooks they provide, doesn't it? – random_user_name Oct 17 '13 at 20:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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