I have created a custom post type for events (performaces of theater plays). Event categories denote plays and the events are performances of the plays. I would like user comments on individual performances (i.e. posts of the event custom-post-type) to apply to the category and appear on all other events of the same category. The question is how to best achieve this.
One (quite bad) idea would be to use the comment_post hook and attach a copy of the comment to all posts of the same category. But first this would not apply to new posts of the category (unless comments are copied when a new post is first saved), change of category would need to be taken care of, … and it does not seem very elegant to duplicate comments this way.
Another idea would be to use the comment_post hook and attach the comment_id as a termmeta to the category and develop a different comments.php to pick up the comments from the category. Seems a bit complicated but not undoable.
Any ideas?
2
Answers
I built my solution based on the proposal from Shoelaced. Since I use a custom taxonomy for the categories it is a little bit different:
I don't want to allow replies to comments, which makes the display quite simple. In my child theme of OceanWP I include a slightly modified comments.php which tests if the post_type is my custom post type, in which case:
...
Would something like this get you started?
I’m sure this could be optimized a bit, but hope this helps.