I have a plain HTML website with WP in a subfolder (/blog). I need to display latest posts from /blog into the plain HTML webpage.

Is there a PHP script or some kind of widget to achieve this?


  • There a lot of solutions to display recent posts from wordpress, you can call a recent posts widget, you can make a wordpress sidebar with recent posts widget and show this sidebar on your page, you can create wp_query or use get_posts functions, so it's your decision, but first, try to do 2 steps from my answer before. – anton May 11 at 19:15

Perhaps you could consider using WP REST API to get the posts with a XMLHttpRequest in javascript instead of trying to get php work on .html file(s).

From the REST handbook,

The WordPress REST API provides an interface for applications to interact with your WordPress site by sending and receiving data as JSON (JavaScript Object Notation) objects.


It provides data access to the content of your site, and implements the same authentication restrictions — content that is public on your site is generally publicly accessible via the REST API, while private content, password-protected content, internal users, custom post types, and metadata is only available with authentication or if you specifically set it to be so.


1) Run php code in html files

You can't run PHP in .html files because the server does not recognize that as a valid PHP extension unless you tell it to. To do this you need to create a .htaccess file in your root web directory and add this line to it:

AddType application/x-httpd-php .htm .html

This will tell Apache to process files with a .htm or .html file extension as PHP files.
(related answer)

2) Use Wordpress functionality outside of wordpress folder

If you able to use php in your html files, you need to include wordpress wp-load.php file to load wordpress functionality. I'm not familiar with your folders' structure, so you will need to modify a path to this file by yourself.

require_once( '../blog/wp-load.php' );
  • 1
    Bear in mind that this will make the server process each HTML file as PHP before sending it to the user which will slow down the site. You would be better looking at the json API and getting the post content using js. – Robert Went May 12 at 0:54
  • Totally agree)) – anton May 12 at 4:15

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