Hi, I am using the Underscores starter theme and I notice that when I use the Content position this removes the <main> tags from index.php and I can’t see why.
This is happening because the position “Content” replaces the current theme’s entire template, in this case index.php. It probably needs to be explained better in the Location tab, where it says:
By default, the layout is applied to the Content position, which is the whole site page.
So it’s not replacing the post content, displayed by the_content() in the above PHP template. Instead, it replaces the whole page content between theme header and footer.
It uses the WP core filter template_include (reference) to replace the theme’s PHP template (index.php, or any other for the matching location) with an internal PHP template (called content.php in the plugin). This calls get_header(), loads the Layout template as the main content, then calls get_footer().
It means that the Layout template replaces index.php completely, and needs to output its own main element. Something like:
This should be equivalent to the call to get_sidebar() in index.php.
I’ll make a note to improve the description of this theme position, and maybe rename it, to clarify what it does. Since there are positions for Document Head and Foot, it could be called Body, with an explanation that it replaces the entire theme template.
By default, the layout is applied to the Content position. This replaces the theme template for the matching location, such as index.php, with a minimal wrapper that loads: the theme header, the layout template as main content, and the theme footer.