0

I currently have a page template that I have striped of all major styling within a theme (twentyninteen-child).

I have a new child theme (event), that this page/template will sit under and am having trouble incorporating it. There are so many posts that say different things, I am getting confused and have crashed my UAT multiple times.

The page will sit separate from the site and will not (at this time) have a header or footer of the larger site that it will sit in. Below is the code that partially works.

<?php /* Template Name: My template */ ?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
    <meta charset="<?php bloginfo( 'charset' ); ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?php wp_head(); ?>
    <?php function mypage_head() {
    echo '<link rel="stylesheet" type="text/css" href="'.get_bloginfo('stylesheet_directory').'/css/style.css">'."\n";
}
add_action('wp_head', 'mypage_head');
?>
</head>
<body class="page-template-connect-home-placeholder">

Is this what I should be doing if I want a page template to have completely different styling to the rest of the site?

EDITED: After trying quite a few things I have just referenced the other themes styling in the template. It's probably not the best way of doing it, but it works. I used the <link rel="stylesheet" href=""> and removed the <?php wp_head(); ?> tag. I need to update the style in the other section as it was thrown out a bit, but can use the other theme fine.

0

The problem is that your theme still load the main style.css sheet, because it is called by wp_head(). See the documentation here

So, in order to not load your theme main stylesheet, you have to add to your functions.php file :

add_action( 'wp_enqueue_scripts', 'yolo_my_custom_template' );
function yolo_my_custom_template(){
    if ( is_page_template( 'name_of_your_page_template.php' ) ) :
      wp_deregister_script('twentynineteen-style');
      wp_deregister_script('twentynineteen-print-style');
    endif;
}
  • I added it into my new themes child and it didn't do anything. – jesstp Sep 23 '19 at 1:54
  • Hi, did you change name_of_your_page_template.php by the real name of your "My template" template file ? – CRavon Sep 23 '19 at 8:28
  • Yes, I ended up just referencing the styles. As this is a completely separate template. Thanks for your help. – jesstp Sep 24 '19 at 1:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.