Support Forum
When I apply a view to The whole page layout, including header and footer, then the source code in the front end becomes:
<html>
<head></head>
<body>
Header View made with Metabox (included with ShortCode inside Body View)
Body made with Metabox (applied to The whole page layout, including header and footer)
Footer on posts made by Metabox (included with ShortCode inside Body View)
</body>
</html>
I tried this with several themes, and always the the same result.
Shouldn't the head tag be left alone and to be output by the theme?
Ideally, "The whole page layout, including header and footer", means the header.php and footer.php but not the head tag, which is not related to display, but functionality.
In any case - how'd you suggest to put back all required head contents when using MetaBox Views?
Usually, we would want a head like so:
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="profile" href="http://gmpg.org/xfn/11">
<?php wp_head(); ?>
</head>
(or similar)
Note:
My goal is to design a whole template, inclusive menu and footer, with MB Views.
Perhaps I am approaching this wrongly...
Hi,
There are three options to render the view:
See my screenshot to get more details https://share.getcloudapp.com/qGuleZzO.
Hello
Yes, I know that.
But when you choose The whole page layout, including header and footer, then the result is a empty head tag, such as I explain in my firs post.
The result will be (in HTML source):
<html>
<head></head>
<body>
HERE WILL DISPLAY THE VIEW ASSIGNED TO The whole page layout, including header and footer
</body>
</html>
As you can see head is empty
This is not good, as head should not be empty, or at least not insert by the plugin, so we could populate it on our own.
Note, this head tag is not coming from theme, it comes form View assigned to the page.
Thanks!
Hi,
To include the header in the view, you can just use the WP function get_header()
{{ mb.get_header() }}
HERE WILL DISPLAY THE VIEW
see more on this documentation https://developer.wordpress.org/themes/basics/template-files/#using-template-files.
or add the <head>
tag to show only the <head>
<head>
<meta charset="{{mb.bloginfo( 'charset' )}}">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="profile" href="http://gmpg.org/xfn/11">
{{ mb.wp_head() }}
</head>
<body>
HERE WILL DISPLAY THE VIEW
</body>
Hummmm...
Ok, here is what I found:
<html><head></head><body>This would be the View content. Whatever we put here, code, HTML, Twig, etc etc.</body></html>
If we insert manually a head tag, it will replace the empty head tag, and produce what we insert in the View
If we call get_header, it also replaces the head tag, and puts in what comes from the theme
So far, so good, I misunderstood how it works, I think.
I thought the view would simply replace all content and not expect any head or else like a "completely blank output"
I can proceed, it is clear now.
Thanks a lot, Long!