Empty head tag when applying View to whole page
- This topic has 4 replies, 2 voices, and was last updated 4 years, 3 months ago by
Beda Schmid.
-
AuthorPosts
-
January 16, 2021 at 6:39 PM #24057
Beda Schmid
ParticipantWhen 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...January 16, 2021 at 9:58 PM #24062Long Nguyen
ModeratorHi,
There are three options to render the view:
- The whole page layout, including header and footer: that means all sections header, main content, footer will be replaced by the view content.
- The layout between header and footer: that means the section main content (post content and sidebar) between the header and footer will be replaced by the view content.
- Only the post content area: that means only the post content will be replaced by the view content, keep the section sidebar.
See my screenshot to get more details https://share.getcloudapp.com/qGuleZzO.
January 16, 2021 at 10:57 PM #24064Beda Schmid
ParticipantHello
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!
January 17, 2021 at 8:48 AM #24067Long Nguyen
ModeratorHi,
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>
January 17, 2021 at 2:47 PM #24071Beda Schmid
ParticipantHummmm...
Ok, here is what I found:
- If we just create a view and assign to The whole page layout, including header and footer, but do NOT insert a head tag, or do NOT call get_header, then the HTML source will be
<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!
-
AuthorPosts
- You must be logged in to reply to this topic.