Is there a way to know if a page is using Gutenberg or not?
The use case is migrating an old post to Gutenberg and letting crafted pages just render themselves with blocks but add some wrapping around old pages which probably won't be migrated since they're just text (Privacy policy and those). They need to coexist at least for a while.
A block editor page can usually be just rendered with
<?php
get_header();
while (have_posts()) :
the_post();
the_content();
endwhile;
get_footer();
While I have that handled for the homepage using a p front-page.php
template, I'd like to have a generic template that can handle both types so I don't have to go slug by slug.
<article>
tag, otherwise where is thepost_class()
function going to go? Or the ID? How will search engines and social networks know which parts of the page are the main content vs the header/footer? What will screen readers do? Note that it's also possible for a posts content to be a mixture of the two. Eitherway you shouldn't need to conditionally wrap the post content, and you shouldn't want to<article>
or<aside>
might not make sense, but you would still want a<section>
or a<main>
tag, or even a<div>
, which tag you use isn't the point, it's that most things be it browsers/screen readers/search engines/etc expect the main content to be wrapped and marked in some way, even if that main content is a homepage layout. This might be adiv
container with an ID, a semantic tag such as<main>
or<section>
, but you always want a container of some sort, even if it doesn't show visually. The canonical answer for the problem you're trying to solve is: don't