Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

98
Views
Trying to create a comments section on my website using Javascript / Wordpress End Points

Ok I'm struggling trying to link up a comments form so it posts comments to my Wordpress CMS.

Here is the HTML from my posts page:

          <h1>Leave a Reply ⩤</h1>
          <form id="form" method="POST">
          <input type="text" name="FIRSTNAME" class="name" placeholder="Enter first name..">
          <textarea id="subject" name="subject" placeholder="Write a comment.."></textarea>
          <input type="submit" value="Submit" id="">
        </form>
        </div> 

and the JS:

  var id = JSON.parse(findQuery("id"));
  fetch(`https://www.someurl.com/wp-json/wp/v2/comments`, {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ post: id, author_name: "X", author_email: "x@gmail.com", content: "test post" }),
  })
    .then((response) => response.json())
    .then((data) => {
      console.log(data);
    });
}
postComment(); 

Would massively appreciate any help with this?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!