I was looking for a way to render a WordPress
page in a custom PHP
based website. I succeeded in that but it is not styled
as it is on WordPress
.
Please tell me how can I fetch the page exactly as it is on WordPress
?
I have this code
to display the webpage
:
<?php include('view/header_copy.php'); ?>
<div class="pt-20 pt-md-18 pt-lg-20 pb-13 pb-md-17 pb-lg-33 px-10 px-md-20 px-lg-20 px-xl-30">
<div id="wp-content-container"></div>
</div>
<script>
fetch('https://blogs.domainnamehere.com/wp-json/wp/v2/pages?slug=success-stories')
.then(response => response.json())
.then(data => {
const page = data[0];
document.getElementById('wp-content-container').innerHTML = page.content.rendered;
})
.catch(error => console.error('Error fetching page:', error));
</script>
<?php include('view/footer_copy.php'); ?>