Leveraging WordPress Comments on Custom Plugin Object page

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:

http://localhost/wordpress/my_object/?id=7

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

Read More

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 ?

Related posts

1 comment

  1. 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.

Comments are closed.