In order to create a static page template that does not use the site’s default stylesheet, I created:

page-custom.php
header-custom.php
footer-custom.php
static.css

For the most part the page is working as intended: it brings in the correct post, but some of the styling from the default style.css is still influencing the content display.

Here is how I have coded it. For the customer header:

<!DOCTYPE html>
<html <?php language_attributes(); ?>>

<head>
    <meta charset="https://wordpress.stackexchange.com/questions/138258/<?php bloginfo("charset'); ?>" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

    <link rel="stylesheet" href="https://wordpress.stackexchange.com/questions/138258/<?php bloginfo("template_url'); ?>/css/static.css">

    <link rel="pingback" href="https://wordpress.stackexchange.com/questions/138258/<?php bloginfo("pingback_url'); ?>">

    <?php wp_head(); ?>
</head>

For the page-static.php. Note, here I have included the line to dequeue the default stylesheet:

<?php
/*
        Template Name: Static Page
*/
?>
<?php wp_dequeue_style( 'style' ); ?>
<?php get_header('custom'); ?>

<?php get_header(); the_post(); ?><!-- this enables the page content to show up below -->

  <body class="static">

<!-- Begin page content -->
<div class="container">
    <div class="main-content">

        <div class="row">
            <h2><?php the_title(); ?></h2>
        </div>
        <div class="main-text">
            <?php the_content(); ?>
        </div>

    </div><!-- end main-content -->
</div><!-- end .container -->

<?php get_footer('custom'); ?>

And for the footer:

  </body>
</html>

I am not sure what I am missing here and would appreciate some more experienced eyes to review and let me know how I can resolve this.

Thanks.

1 Answer
1

You did call the header twice in your page-static.php. You can remove the second call (before the_post()).

If you remove the second call of the_header(), the Stylesheet should not be delivered anymore.

<?php
/*
        Template Name: Static Page
*/
?>
<?php wp_dequeue_style( 'style' ); ?>
<?php get_header('custom'); ?>

<?php the_post(); ?><!-- this enables the page content to show up below -->

  <body class="static">

<!-- Begin page content -->
<div class="container">
    <div class="main-content">

        <div class="row">
            <h2><?php the_title(); ?></h2>
        </div>
        <div class="main-text">
            <?php the_content(); ?>
        </div>

    </div><!-- end main-content -->
</div><!-- end .container -->

<?php get_footer('custom'); ?>

Leave a Reply

Your email address will not be published. Required fields are marked *