Header and Footer Don’t Right-Justify with Custom Page Template
-
I need to use some PHP on a specific page, so I am attempting to create a custom page template (PHP file). I actually have a number of these custom page templates that work great in Twenty Sixteen, but I want to move to a block theme, so I’ve been trying to re-create the custom page templates for Twenty Twenty Three.
That part works just fine. Using the following code in a file called “page-test-custom-template.php,” which I saved in the root folder I created for a child-theme of Twenty Twenty Three, I can assign the custom template to a page:
<?php /** * This is a test custom template for Twenty Twenty Three. * * Template Name: Test Custom Template * */ ?> <!DOCTYPE html> <html <?php language_attributes(); ?>> <head> <meta charset="<?php bloginfo( 'charset' ); ?>"> <meta name="viewport" content="width=device-width, initial-scale=1"> <?php $title = get_the_title(); $site_name = get_bloginfo('name'); $page_title = $title . ' - ' . $site_name; ?> <title><?php echo $page_title; ?> - </title> <?php wp_head(); ?> </head> <body <?php body_class(); ?>> <?php wp_body_open(); ?> <div class="wp-site-blocks"> <header class="wp-block-template-part"> <?php block_header_area(); ?> </header> <main class="wp-block-group"> <div class="wp-block-group has-global-padding is-layout-constrained"> <h1 class="wp-block-post-title"> <?php echo $title; ?> </h1> </div> <div style="height:32px" aria-hidden="true" class="wp-block-spacer" ></div> <?php echo do_blocks('<!-- wp:post-content {"layout":{"inherit":true}} /-->'); ?> <div class="wp-block-group has-global-padding is-layout-constrained"> <?php echo '<p>Here is some text from PHP.</p>'; ?> </div> <div class="wp-block-group"> <?php $str = '<!-- wp:post-comments {"style":{"spacing":{"padding":{' . '"top":"var(--wp--custom--spacing--medium, 6rem)"}}}} /-->'; echo do_blocks($str); ?> </div> </main> <footer class="wp-block-template-part site-footer"> <?php block_footer_area(); ?> </footer> </div> <?php wp_footer(); ?> </body> </html>
The PHP output works fine, too, so I believe I’m nearly there; however, the header and footer don’t right-justify the navigation block or the credits, respectively:
You can see the problem at the link below, and compare it to any of the other pages on the test site to see how the header and footer should look.
I’ve been wading through the CSS, and I haven’t been able to find the issue.
The page I need help with: [log in to see the link]
- The topic ‘Header and Footer Don’t Right-Justify with Custom Page Template’ is closed to new replies.