• Following steps found online, I’ve created a new WP theme (very basic as of now) using WAMP localhost.

    Everything I’ve done as per the various online tutorials has worked except the final step of loading the stylesheet. I’ve tried at least a dozen different variations of code found online in my function.php file to no avail. Nothing I add to the style.css has any effect on my site. If I add the css to the additional css section, it works. So what am I doing wrong in the function.php file that is preventing the stylesheet from loading

    Here is my current functions.php code:

    <?php wp_register_style( ‘style’, get_stylesheet_url() );

    wp_enqueue_style( ‘style’, get_stylesheet_uri() );

    ?>

    I’ve also tried this (which didn’t work):

    <?php

    function my_assets() {
    wp_register_script( ‘style’, get_stylesheet_directory_uri() . ‘/style.css’ );
    wp_enqueue_script( ‘style’ );
    }

    add_action( ‘wp_enqueue_scripts’, ‘my_assets’ );

    • This topic was modified 8 years, 4 months ago by stevecorwin.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator t-p

    (@t-p)

    I’ve created a new WP theme

    Check against this guide what you have created: Theme Handbook

    Thread Starter stevecorwin

    (@stevecorwin)

    The Theme handbook is the primary resource I used to get where I am. I’ve added the code suggested in the handbook to my functions.php file and nothing I add to my style.css has any effect on my site.

    Thread Starter stevecorwin

    (@stevecorwin)

    I’m at my wits end here. I thought I was starting to have a handle on this stuff but I’ve spent 3 days trying to get my style.css to have any effect on my site and have failed. I’ve tried everything I could find online. The only thing I can think of to do is beg you guys for assistance. I’ve deleted my function.php file to start over. The following is the complete code I have so far for my style.css, header.php, footer.php, and index.php.

    *****index.php code:
    <?php

    get_header();

    if ( have_posts() ) :
    while ( have_posts() ) : the_post(); ?>

    <article class=”post”>
    <h2>“><?php the_title() ?></h2>
    <?php the_content() ?>
    </article>
    <?php endwhile;

    else :
    echo ‘<p>There are no posts!</p>’;

    endif;

    get_footer();

    ?>

    *****style.css code:
    /*
    Theme Name: Prince
    Author: Steve Corwin
    Author URI: http://bridgetales.com
    Version: 1.0
    */

    body {
    font-family: Arial, sans-serif;
    font-size: 16px;
    color: green;
    }
    /* unvisited link */
    a:link {
    color: pink;
    }

    /* visited link */
    a:visited {
    color: green;
    }

    /* mouse over link */
    a:hover {
    color: hotpink;
    }

    /* selected link */
    a:active {
    color: red;
    }

    *****header.php code:
    <!DOCTYPE html>
    <html <?php language_attributes(); ?>>

    <head>
    <meta charset=”<?php bloginfo( ‘charset’ ); ?>”>
    <title><?php bloginfo( ‘name’ ); ?></title>
    <?php wp_head() ?>
    </head>

    <body <?php body_class(); ?>>
    <div class=”container”>
    <header class=”site-header”>
    <h1>“><?php bloginfo( ‘name’ ); ?></h1>
    <h4><?php bloginfo( ‘description’ ); ?></h4>
    </header>

    ****footer.php code:
    <hr>
    <h2>The Footer!</h2>
    <footer class=”site-footer”>
    <p><?php bloginfo( ‘name’ ) ?></p>
    </footer>
    </div> <!– closes <div class=container”> –>

    <?php wp_footer() ?>
    </body>
    </html>

    Can someone please tell me what I need to do from here to get the style.css to take effect?

    p.s. all above files located in root theme folder

    • This reply was modified 8 years, 4 months ago by stevecorwin.

    You’re using wp_register_script() and wp_enqueue_script(), which are for loading JavaScript. Instead, you need to use wp_register_style() and wp_enqueue_style().

    Thread Starter stevecorwin

    (@stevecorwin)

    Wow. just. wow. I guess deleting the functions file and starting over was the key. While waiting to see if anyone would comment here and assist, I decided to go through the process again of creating a functions file and adding code to enqueue the stylesheet. I put the following snippet (which I’ve done at least 10 times in the last 2 days) and updated my site. voila! it worked.

    <?php
    wp_enqueue_style( ‘style’, get_stylesheet_uri() );
    ?>

    I have no idea why it hadn’t been working. Maybe the functions file itself was corrupt. I don’t know. Just glad it’s working.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘New created theme not loading style.css’ is closed to new replies.