BTW I forgot to mention that calling
get_header() before and get_Footer(); after the previous code doesn’t work as expected because it doesn’t strictly apply / respect the theme configuration
Hi @solariane,
I’m checking this further and we’ll follow up here as soon as possible. 🙂
@foosantos thank you for your help.
Two things that might help :
- action
wp_body_open is not called
- the “basic / default” WP visual header and footer – I mean the one inside <body> are called with my above “solution”
So for now, I do some “post-processing” : get rid of those html fragment through DOMXpath and rewrite some tags in the <head>
A cleaner way to do it, might be to build a $post object and than apply the model on it…
If these are PHP-based templates that you are including, you need to add the wrapping code yourself. Something like this at the top of the file:
<!doctype html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<?php wp_body_open(); ?>
And something like this at the bottom of the file:
<?php wp_footer(); ?>
</body>
</html>
You could also stick that code into a header.php and footer.php file and call them with get_header() and get_footer(), respectively.
@greenshady yes it’s way cleaner with the header.php and footer.php trick.
Still have some incorrect stuff in the <head> ( title, canonical ) which might be set manually
Do you know if it’s possible from PHP to something even “cleaner” in my eyes : Create a $p = WP_Post ( with my virtual URL and the correct Title + the info specifying which wp_template to apply ) and then do :
get_header();
apply_filters( 'the_content', $p->post_content )
get-footer();
I’m not 100% sure on what you’re asking. If you can explain in a bit more detail, I may be able to help.