Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

linking css

I cannot get my wordpress site to link to the CSS file. I'm running MAMP Pro. Here's my code:

header.php file:

<!DOCTYPE html>
<html>
<head>
    <title>
        <?php
            wp_title( '-', true, 'right' );

            bloginfo( 'name' );
        ?>
    </title>
    <?php wp_head(); ?>
</head>

<body>
    <p>This is the header</p>

    <?php

        $args = array(
            'menu' => 'main-menu'

            );

        wp_nav_menu( $args );

    ?>

my functions.php file:

<?php

function theme_styles() {
wp_enqueue_style( 'main', get_template_directory_uri() . '/style.css' );

}

add_action( 'wp-enqueue_scripts', 'theme_styles' );

// Enable custom menus
add_theme_support( 'menus' );

?>

my style.css file (I'll just post the metadata portion):

/*
Theme Name: Portfolio for Allison Grayce
Theme URI: http://wptreehouse.com/portfolio-project/
Description: A custom WordPress portoflio site for Allison Grayce built for the Treehouse tutorial series, "How to Build a WordPress Theme."
Author: Zac Gordon
Author URI: http://blog.teamtreehouse.com/author/zacgordon
Version: 1.0
Tags: clean, light, responsive, two-column, custom-post-types, custom-fields, portfolio

License: GNU General Public License v2.0
License URI: http://www.gnu.org/licenses/gpl-2.0.html

This theme goes along with the How to Build a WordPress Theme tutorial series from teamtreehouse.com
*/

Nothing I do has been able to get the stylesheet to link up. I've tried changing the Theme URI in the style.css file, but to no avail. If anyone has any tips, I'd sure appreciate it.

2 Answers

good god... hours of looking through forums and the Wordpress codex, and the mistake was simply that I erroneously used a hyphen in place of an underscore when I typed wp_enqueue_scripts as wp-enqueue_scripts in the add_action function.

Ugh.

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Oh man, rough! I just uploaded some project files, which will hopefully alleviate this problem in the future.