Title: Theme Options &#8211; CSS div Background Image
Last modified: August 20, 2016

---

# Theme Options – CSS div Background Image

 *  [whispere](https://wordpress.org/support/users/whispere/)
 * (@whispere)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/theme-options-css/)
 * What code do I need to be able to change a background image of a particular div
   in the Themes Option Panel.
 * I wanted to set it up so I would only have to type the name of the correct image
   I want it to put in the background.
    OPTIONS.PHP
 *     ```
       $options[] = array( "name" => "Menu Background",
       						"desc" => "silver, green, black",
       						"id" => "menu_template",
       						"type" => "textarea");
       ```
   
 * If I were changing something in a php file I know I could just put `<?php echo
   of_get_option('menu_template'); ?>`right where I want it to insert the text, 
   but what it the most efficient way to target the background style so It can be
   switched out.
 * Is there a good way of adding the style w/php?
 *     ```
       .navbar {
       background: url(images/bar.png) top left repeat;
       width: 800px;
       height: 35px;margin: 0px auto;
       }
       ```
   
 * What I want to do is basically
 *     ```
       .navbar {
       background: url(images/<?php echo of_get_option('menu_template'); ?>.png) top left repeat;
       width: 800px;
       height: 35px;margin: 0px auto;
       }
       ```
   
 * But I know unicorns don’t exist and I know I can’t add the php to the css like
   that so please help. I know this is a stupid question to most of you but I am
   such a newbie w/ wordpress & php

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

 *  [shirazdrum](https://wordpress.org/support/users/shirazdrum/)
 * (@shirazdrum)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/theme-options-css/#post-2606482)
 * Unless you are making a function for a custom theme and letting the user insert
   the image in the options, just put the link to the image in the url(), no need
   for anything else.
 * Another way would be to copy that image to your stylesheet directory in a folder
   called “images” and then you call it like:
 * `background: #YOUR COLOR CODE url(images/blahblah.png) top left repeat;`
 *  Thread Starter [whispere](https://wordpress.org/support/users/whispere/)
 * (@whispere)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/theme-options-css/#post-2606507)
 * Thanks for the reply, and actually I am making It for someone else. I know its
   a lot simpler for me just to go in and change it manually but I want them to 
   be able to switch the menu when they would like themselves. Its something they
   have requested and I haven’t created themes with theme options before.
 * I have been able to add every other part needed in the themes option except this
   one.
 *  [walkerofbass](https://wordpress.org/support/users/dougwalker619/)
 * (@dougwalker619)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/theme-options-css/#post-2606843)
 * I accomplished this with inline css…
    <div class=”banner” style=”background:url(‘
   <?php echo $newmatic_options[‘themebanner’]; ?>’) repeat;”>

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

The topic ‘Theme Options – CSS div Background Image’ is closed to new replies.

## Tags

 * [background](https://wordpress.org/support/topic-tag/background/)
 * [css](https://wordpress.org/support/topic-tag/css/)
 * [image](https://wordpress.org/support/topic-tag/image/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [style](https://wordpress.org/support/topic-tag/style/)
 * [switch](https://wordpress.org/support/topic-tag/switch/)

 * 3 replies
 * 3 participants
 * Last reply from: [walkerofbass](https://wordpress.org/support/users/dougwalker619/)
 * Last activity: [13 years, 8 months ago](https://wordpress.org/support/topic/theme-options-css/#post-2606843)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
