2016-09-05 3 views

답변

1

get_post_meta() 함수를 사용하면이 기능을 사용할 수 있습니다. 은 첫 번째 매개 변수에서 게시물 ID를 전달할 수 있으며, 초에 custom_field_name을 사용할 수 있습니다. 아래 코드에서 데이터베이스 또는 에서 사용할 수 있음을 확인하십시오.

이 코드를 사용해보십시오.

<?php 

    if(is_single() & !is_home()) 
    { 
     $myfield = 'custom_field_name'; // Change this to the name of the custom field you use.. 
     $postimage = get_post_meta($post->ID, $myfield, true); 
      if($postimage) 
      { 
       // If the field has a value.. set image path using value... 
      } 
      elseif(!$postimage) 
      { 
       // If no value than set Default image path.. 
      } 
    } 
?> 
관련 문제