0

Okay. I've been trying to link the css stylesheets to my webpages. I've been scratching my head trying to figure out what I am doing wrong. Any ideas?

functions.php

<?php 

function roofers_wp_resources() { 
    wp_enqueue_style('normalize', get_stylesheet_uri());
    wp_enqueue_style('style', get_stylesheet_uri());   
} 

add_action('wp_enqueue_scripts', 'roofers_wp_resources');

?>

header.php

<!DOCTYPE html>
<html>
    <head>
        <title>R.J Roofers</title>
        <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <?php wp_head(); ?> 

    </head>
<body>

front-page.php

<?php get_header(); ?>
<div class="main-container">
    <header class="main-header">
        <!--        <h1 class="logo-name"><li><a href="index.html">R.J Roofer</a></li></h1>
         -->        <h1 class="logo-name"><a href="index.html">R.J Roofer</a></h1>

                <nav class="main-nav">
                    <li class="nav-item-1"><a href="#">home</a></li>
                    <li><a href="services.html">services</a></li>
                    <li><a href="#">gallery</a></li>
                    <li><a href="about.html">about us</a></li>
                    <li><a href="contact.html">contact</a></li>
                </nav>
            </header>
        <div class="quote-box-1">

            <div class="quote-box">
                <p class="quote-box-title">HOME ROOFING BRISBANE NO.1 FOR ROOF RESTORATIONS AND ROOF REPLACE</p>
                <button class="quote-btn-1">BOOK A FREE QUOTE</button>
            </div>
        </div> 
More Code..
1
  • wp_enqueue_style( 'core', 'style.css', false ); the second parameter should contain the name of the file you are en queueing. So more like wp_enqueue_style('normalize', get_stylesheet_uri() . '/normalize.css'); Commented Jun 23, 2017 at 20:24

1 Answer 1

1

get_stylesheet_uri() gives full url to your style.css file, so in your case it's good only if you want to enqueue the style.css file. For the second file, you need to pass a full url including the name of the file. Assuming your normalize file called normalize.css:

function roofers_wp_resources(){
    wp_enqueue_style('my-theme-style', get_stylesheet_uri());
    wp_enqueue_style('normalize', get_template_directory_uri() . '/normalize.css');
}
add_action('wp_enqueue_scripts', 'roofers_wp_resources');

Notice that if you working on a child theme, you need to change get_template_directory_uri() to get_stylesheet_directory_uri().

Sign up to request clarification or add additional context in comments.

2 Comments

Okay. but the issue remains: i cannot even get the style.css working!
The file is not loading in the page? Check for any errors in the console (Right click in the page->Inspect Element->go to "console" tab)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.