<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>::TEST::</title>
</head>
<body>
<div id="content">
</div>
<script src="https://code.jquery.com/jquery-3.1.1.js" type="text/javascript"></script>
<script>
jQuery(document).ready(function(){
jQuery.get("demo_test.php", function(data, status){
jQuery('#content').html(data);
});
});
</script>
</body>
</html>
this is just a normal html file i have placed at wordpress root with the name of “test.html” and created another file called “demo_test.php” with the below code
<?php
include 'wp-load.php';
$args = array(
'post_type' => 'post',
'posts_per_page' => 1
);
$query = new WP_Query($args);
if($query->have_posts()):
$data = '';
while($query->have_posts()):$query->the_post();
$data .= '<h1>'.get_the_title().'</h1>';
$data .= '<div class="description">'.get_the_content().'</div>';
endwhile;endif;
echo $data;
What it does basically is calls demo_test.php on page load and returns 1 latest post.
]]>