3 posts
  • Exclusive Author
  • Has been a member for 1-2 years
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
  • Exclusive Author
  • Has been a member for 1-2 years
ismayanti says

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

3437 posts Ruben Bristian
  • Most Wanted Bounty Winner
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Has been a member for 6-7 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Won a Competition
  • Bought between 100 and 499 items
  • Exclusive Author
  • Referred between 500 and 999 users
+5 more
KrownThemes says

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

3 posts
  • Exclusive Author
  • Has been a member for 1-2 years
ismayanti says

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

3437 posts Ruben Bristian
  • Most Wanted Bounty Winner
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Has been a member for 6-7 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Won a Competition
  • Bought between 100 and 499 items
  • Exclusive Author
  • Referred between 500 and 999 users
+5 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.

by
by
by
by
by
by