2014-04-15 5 views
-2

저는 워드 프레스 플러그인을 만들고 있습니다. 함수를 등록하고 if 문을 사용합니다. 코드는 다음과 같습니다WordPress의 PHP 함수에서 스타일을 가져올 수 없습니다.

function custom_twitter() { 
if($twitter!=''){ 
?> 
<style type="text/css"> 
    .google_area {top: 40px;} 
    .youtube_area {top: 80px;} 
</style> 
<?php } if($twitter=''){ ?> 

    <style type="text/css"> 
     .google_area {top: 80px;} 
     .youtube_area {top: 120px;} 
    </style> <?php 

} 

} 
add_action('wp_head', 'custom_twitter'); 

난 다음 제 1 호 양식를 얻을 수 $twitter 값을 설정하지 않을 때처럼 작동 할 수있는 기능이 필요하고 내가 값을 설정할 때 다음이 초 스타일를 얻을 것이다. 그러나 그것은 나를 위해 작동하지 않습니다. 제발 도와주세요.

답변

0

global $twitter;을 함수에 추가하거나 함수의 매개 변수로 전달하십시오.

0

PHP에서 두 변수를 = 대신 ==으로 비교합니다.

function custom_twitter() { 
if($twitter!=''){ 
?> 
<style type="text/css"> 
    .google_area {top: 40px;} 
    .youtube_area {top: 80px;} 
</style> 
<?php } if($twitter==''){ ?> 

    <style type="text/css"> 
     .google_area {top: 80px;} 
     .youtube_area {top: 120px;} 
    </style> <?php 

} 

} 
add_action('wp_head', 'custom_twitter'); 
+0

그러나 어떤 해결책도 작동하지 않습니다. –

+0

정확히 $ twitter는 무엇입니까? 나는 $ twitter의 가치가 당신의 코드에서 NULL이라고 생각한다. – Kwader

관련 문제