2016-09-22 3 views
0

주 코드는 아래쪽에 있습니다.WordPress 테마 사용자 정의 프로그램에서 PHP로 문자열 반향하기

WordPress Theme Customizer를 사용자 지정하고 문제가 발생했습니다.

기본적으로 선택할 수있는 많은 배경 이미지가 있습니다. 아래의 코드에서 '미묘한'선택이 이루어진 경우 배경 이미지 URL은 url.com/image.png가됩니다.

그러나 '아무것도 없음'을 선택한 경우 다른 선택자에서 선택한 색상으로 배경 이미지를 가져 오려면 예를 들어, 나는 뱉어하려는 :

'{background: <?php echo $color_scheme_2; ?>;}' 

난 당신이 에코의 에코을 사용할 수 없습니다 이해하지만, 나는 일하러 가야 제대로이 문제를 코딩하는 방법을 모르겠어요.

$color_scheme_end2 = get_option('color_scheme_end2'); 
$example_position = get_theme_mod('background_image'); 
if($example_position != '') { 
    switch ($example_position) { 
     case 'nothing': 
      // ** This is where I want the color_scheme2 to be spit out as the background color ** 
      break; 
     case 'subtle': 
      echo '<style type="text/css">'; 
      echo '.site-header {background-image: url("http://www.url.com/image.png/")'; 
      echo '</style>'; 
      break; 

는 당신에게 당신이 제공 할 수있는 지침 너무 감사합니다

여기에 전체 코드입니다!

답변

0

이 당신이 코드를 업데이트 할 수있는 방법, 당신은 연결 연산자를 사용할 수있다 (.) : 충분히 쉬운

$color_scheme_end2 = get_option('color_scheme_end2'); 
$example_position = get_theme_mod('background_image'); 
if($example_position != '') { 
    switch ($example_position) { 
     case 'nothing': 
      // ** This is where I want the color_scheme2 to be spit out as the background color ** 
      echo '<style type="text/css">'; 
      echo '.site-header {background: '.$color_scheme_2.';}'; 
      echo '</style>'; 
     break; 
     case 'subtle': 
      echo '<style type="text/css">'; 
      echo '.site-header {background-image: url("http://www.url.com/image.png/")'; 
      echo '</style>'; 
     break; 
+0

! 고맙습니다! – Perry