Skip to content

Instantly share code, notes, and snippets.

@Steveorevo
Last active March 25, 2023 06:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Steveorevo/96d8015bcf353221e1cf0cd6b89bb766 to your computer and use it in GitHub Desktop.
Save Steveorevo/96d8015bcf353221e1cf0cd6b89bb766 to your computer and use it in GitHub Desktop.
The twenty twenty two index.php + generic/minimalist php template support
<?php
// There is nothing output here because block themes do not use php templates.
// There is a core ticket discussing removing this requirement for block themes:
// https://core.trac.wordpress.org/ticket/54272.
?><!DOCTYPE html>
<html>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<title><?php wp_title( '|', true, 'right' ); ?></title>
<link rel="stylesheet" href="<?php echo esc_url( get_stylesheet_uri() ); ?>" type="text/css" />
<style>
h1, h2 {
display: none;
}
#wpadminbar {
margin-top: 0;
}
</style>
<?php wp_head(); ?>
</head>
<body>
<div class="wp-site-blocks">
<h1><?php bloginfo( 'name' ); ?></h1>
<h2><?php bloginfo( 'description' ); ?></h2>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h3><?php the_title(); ?></h3>
<?php the_content(); ?>
<?php wp_link_pages(); ?>
<?php edit_post_link(); ?>
<?php endwhile; ?>
<?php
if ( get_next_posts_link() ) {
next_posts_link();
}
?>
<?php
if ( get_previous_posts_link() ) {
previous_posts_link();
}
?>
<?php else: ?>
<p>No posts found. :(</p>
<?php endif; ?>
<?php wp_footer(); ?>
</div>
</body>
</html>
@lmstearn
Copy link

Thank you, and works for Twenty Twenty-Three!
Using just the suggested line include ABSPATH . WPINC . '/template-canvas.php'; works as well, but the forum content is squinched to the centre of the page, as per style of the theme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment