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 trialDon Shipley
19,488 Pointsphp wordpress function
Using wordpress on localhost. Just placing the function inside the function.php getting an error on the begging and end of the function which is the }. I do not understand why.
function theme_styles () {
wp_enqueue_style ('normalize', get_template_directory_uri() . '/css/normalize.css' );
wp_enqueue_style ('googlefonts', 'http://fonts.googleapis.com/css?family=New+Rocker' );
wp_enqueue_style ('main', get_template_directory_uri() . '/style.css' );
}
5 Answers
banu babanu
8,152 PointsHello,please post your function.php file.
banu babanu
8,152 PointsWhat is the error message exactly?
Don Shipley
19,488 PointsFatal error: Cannot redeclare theme_styles() (previously declared in C:\wamp\www\brewerycasino\wp-content\themes\brewsino\functions.php:3) in C:\wamp\www\brewerycasino\wp-content\themes\brewsino\functions.php on line 11 Call Stack
Time Memory Function Location
1 0.0000 143752 {main}( ) ..\index.php:0 2 0.0050 145872 require( 'C:\wamp\www\brewerycasino\wp-blog-header.php' ) ..\index.php:17 3 0.0050 156448 require_once( 'C:\wamp\www\brewerycasino\wp-load.php' ) ..\wp-blog-header.php:12 4 0.0050 163544 require_once( 'C:\wamp\www\brewerycasino\wp-config.php' ) ..\wp-load.php:29 5 0.0060 224400 require_once( 'C:\wamp\www\brewerycasino\wp-settings.php' ) ..\wp-config.php:90
banu babanu
8,152 PointsYou should have a duplicate code in your theme functions.php Serch for function theme_styles()
Don Shipley
19,488 PointsThank you for your help. Just to let you know, the problem was in the style.css. I am not sure what it was. The template read the css file. I copied the style.css deleted it opened a new file pasted the old css into it and named it the same style.css. That fixed my problem. Wish I knew what the problem was. Maybe it save the old style as a text with the name of css.
banu babanu
8,152 PointsCan you post the header.php file?
Don Shipley
19,488 Points<!DOCTYPE html>
<html>
<head>
<title><?php
wp_title('-' , true, 'right');
bloginfo('name');
?></title>
<?php wp_head();?>
</head>
<body> <div class="main-header clearFloat"> <p>This is the Header</p> <section class="note"> <p>This site is for demonstration purposes only.</p> </section>
</div><!-- end header --> <div class="main-nav"> <nav> <div class="menu"><div id="menu-lines"> </div> </div> <?php
$args = array(
'menu' => 'main-menu',
'echo' => false
);
echo strip_tags(wp_nav_menu($args), '<ul><li><a>');
?>
</nav>
</div> <! end main nav -->
<div class="main-wrapper">
Don Shipley
19,488 PointsDon Shipley
19,488 Points<?php
function theme_styles() {
wp_enqueue_style ('normalize', get_template_directory_uri() . '/css/normalize.css' );
wp_enqueue_style ('googlefonts', 'http://fonts.googleapis.com/css?family=New+Rocker' );
wp_enqueue_style ('main', get_template_directory_uri() . '/style.css' );
}
add_action('wp_enqueue_scripts', 'theme_styles');
//Enable custom menus add_theme_support('menus'); ?>
Just the beginning of the functions.. This is all that is in the functions at this time.
Thank you for your reply