Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

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 ?

share|improve this question
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

1 Answer 1

up vote 5 down vote accepted

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.
share|improve this answer
    
Nice solution. WP has some phenomenal power with the hooks they provide, doesn't it? –  cale_b Oct 17 '13 at 20:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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