Support » Themes and Templates » Theme Options – CSS div Background Image

Theme Options – CSS div Background Image

  • 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[] = 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)
  • 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;

    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.

    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.