Title: Undefined Variable
Last modified: August 20, 2016

---

# Undefined Variable

 *  Resolved [Red Deer Web Design](https://wordpress.org/support/users/bdbolin/)
 * (@bdbolin)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/undefined-variable/)
 * Hey guys, I’m creating a theme and have debug turned on.
 * I added: `<?php body_class($class); ?>` to my `<body>`
 * Now I’m getting this Notice on every page. Anything I can do to remove the notice?
 *     ```
       Notice: Undefined variable: class in /Users/bdbolin/Desktop/MAMP/wp-content/themes/Oasis/index.php on line 2
       class="page page-id-174 page-parent page-template-default">
       ```
   

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

 *  [popper](https://wordpress.org/support/users/julialasarte/)
 * (@julialasarte)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/undefined-variable/#post-2866345)
 * Either define the variable, or turn error reporting for notices off.
 *  [Christine Rondeau](https://wordpress.org/support/users/crondeau/)
 * (@crondeau)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/undefined-variable/#post-2866346)
 * Try changing it to `<body <?php body_class(); ?>>` instead.
 *  Thread Starter [Red Deer Web Design](https://wordpress.org/support/users/bdbolin/)
 * (@bdbolin)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/undefined-variable/#post-2866349)
 * [@christine](https://wordpress.org/support/users/christine/) – I think that worked!
   Thanks guys! Can you tell me how that’s different than what I put? Like is there
   a different instance that mine would have worked better?
 *  [Christine Rondeau](https://wordpress.org/support/users/crondeau/)
 * (@crondeau)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/undefined-variable/#post-2866350)
 * If you read the codex – [http://codex.wordpress.org/Function_Reference/body_class](http://codex.wordpress.org/Function_Reference/body_class)
   
   You’ll see that $class, is optional & can be either an array of class names or
   a string with space-separated classes names. So it needs to be defined. I never
   use it and just let WordPress set the classes.

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

The topic ‘Undefined Variable’ is closed to new replies.

 * 4 replies
 * 3 participants
 * Last reply from: [Christine Rondeau](https://wordpress.org/support/users/crondeau/)
 * Last activity: [13 years, 10 months ago](https://wordpress.org/support/topic/undefined-variable/#post-2866350)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
