I have the static website template on the following domain : example.com and I have wordpress site in the sub domain : sub.example.com I want a code to get the latest post ( just post title ) from the WordPress site to the static site in a dynamic way and when visitor clicked, go to the WordPress site to see full post .

  • did you see my answer? does it work for you? – Andrea Somovigo Jan 22 at 10:17

From your static page you can make a jQuery GET request ( using jQuery is not mandatory though can be the easiest way) to the default endpoint posts of the WP rest of your installation.

More info about WP REST here: https://developer.wordpress.org/rest-api/

<!DOCTYPE html>
<html lang="en">
  <meta charset="UTF-8">    
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

  <ul id="remoteList">



          $('#remoteList').append('<li><a href="'+post.link+'" target="_blank">'+post.title.rendered+'</a></li>')
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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