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?
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.Sign up to join this community
From the REST handbook,
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.
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' );