Using an API plugin i have been able to build a site that combines content from multiple Wordpress websites. I want to give users the ability to quickly leave a comment for one of these posts without having to navigate to the source website. I was able to copy the comment code from the source site, but the form redirects to the source website.

I was thinking the easiest way around all of this would be to just directly insert the comment into wp_comments. The table structure is very simple and shouldnt cause any trouble. Is this the best solution or is there something i am unaware of that could solve this problem.

1 Answer 1


This quite rare setup so it is hard to recommend one way or another.

Having worked with comments before I would recommend to stick with WordPress API functions (wp_insert_comment() and so on) for manipulating them. While DB structure is indeed simple you don't account for all the hooks firing and other things that might be happening.

For example once in the past I had been deleting comments from database directly for reasons... And then one day found years worth of orphan metadata for them that had been left behind. :)

  • I see your point and generally I would opt for using what's already there. Issue is its a different domain. I would have to post the data to another domain and redirect back or even use Ajax. Either way it would require some extra nuts and bolts to fit together. I still think direct Inserts would work best since I have the dB string for all of the databases. Would beat having to write a custom script and place it on all the sites. Potentially opening the door to spam. Does WP not have a generic comment post url that would accept a request through ajax? Commented Jul 18, 2016 at 17:21
  • You could try POSTing to wp-comments-post.php I am just entirely not sure that would work. It might. Otherwise you have to create some kind of listener in any case, in which case API is wiser than DB manipulation and not much more effort.
    – Rarst
    Commented Jul 18, 2016 at 17:25

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.