3 posts
  • Has been part of the Envato Community for over 1 year
  • Sells items exclusively on Envato Market
ismayanti says

Hi all, Im new in PHP, please help me to solve the problem. I want to create multiple background in my theme but have trouble, this is the code :

array( 'id' => 'background-img', 'label' => 'Choose Background', 'std' => 'pattern-0', 'type' => 'radio-image', 'section' => 'styling', 'class' => ' ', 'choices' => array( array( 'value' => 'pattern-0', 'label' => 'Default', 'src' => get_template_directory_uri() . '/functions/images/pattern-0.png' ), array( 'value' => 'pattern-1', 'label' => 'Pattern-1', 'src' => get_template_directory_uri() . '/functions/images/pattern/pattern-1.png' ), array( 'value' => 'pattern-2', 'label' => 'Pattern-2', 'src' => get_template_directory_uri() . '/functions/images/pattern/pattern-2.png' ), array( 'value' => 'pattern-3', 'label' => 'Pattern-3', 'src' => get_template_directory_uri() . '/functions/images/pattern/pattern-3.png' ) ) ),

And Call with this :

if ( of_get_option('background-img') != '' ){ if ( of_get_option('background-img') != '' ) { $styles .= '.background-img { background: url('.get_template_directory_uri().'/functions/images/pattern/pattern-0.png) repeat; }'."\n"; }else if( of_get_option('background-img') != '' ){ $styles .= '.background-img { background: url('.get_template_directory_uri().'/functions/images/pattern/pattern-1.png) repeat; }'."\n"; }else if( of_get_option('background-img') != '' ){ $styles .= '.background-img { background: url('.get_template_directory_uri().'/functions/images/pattern/pattern-2.png) repeat; }'."\n"; }else{ $styles .= '.background-img { background: url('.get_template_directory_uri().'/functions/images/pattern/pattern-3.png) repeat; }'."\n"; } }
3 posts
  • Has been part of the Envato Community for over 1 year
  • Sells items exclusively on Envato Market
ismayanti says

The background doesn’t change when I select from Optiontree panel. What the right code to call it?

3711 posts Ruben Bristian
  • Sells items exclusively on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $750,000+ on Envato Market
  • Has been part of the Envato Community for over 6 years
+10 more
KrownThemes says

Where did you get this code from? It’s ot_get_option, not of_get_option ....

3 posts
  • Has been part of the Envato Community for over 1 year
  • Sells items exclusively on Envato Market
ismayanti says

The code from the internet. I change to ot_get_option but it same with before, the background doesn’t change

3711 posts Ruben Bristian
  • Sells items exclusively on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $750,000+ on Envato Market
  • Has been part of the Envato Community for over 6 years
+10 more
KrownThemes says

Well, you aren’t outputting the background anywhere. That code is useless. Output ot_get_option(‘background-img’) somewhere. You have the same if statement with the same result four times. You should first learn PHP or programming basics before playing with frameworks and stuff.

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by