2014-08-28 3 views
1

안녕하세요 사용자 정의 분류 페이지에 ACF를 표시하는 데 문제가 있습니다.ACF 필드가 Wordpress 사용자 정의 분류 페이지에 표시되지 않습니다.

맞춤 세금은 '대상'이며 페이지는 taxomony-destinations.php이고이 필드의 이름은 'destination_landing_image'입니다. 다음과 같이 나는 'mysite.com/destinations/coutryname'에 표시하기 위해 노력하고있어 :

<?php if (have_posts()) : while (have_posts()) : the_post(); 
$destination_landing_image = get_field('destination_landing_image'); 
<img src="<?php echo $destination_landing_image['url'] ?>" alt="<?php echo $destination_landing_image['alt'] ?>"> 
<?php endwhile; endif; ?> 

이상하게 사용자 정의 포스트 유형 내에서 ACF 필드 (휴일) 낮를 표시 않는 문제의 페이지 페이지에서. 그래서 첫 번째로 루프 내에서 올바르게 호출하고 있다고 생각하십니까? 두 번째로 사용자 정의 분류법을 사용할 올바른 유형의 페이지입니까?

나는 불행하게도, 개발자 아니에요 :(하지만 당신은 당신이 당신이 단지 get_field()을 사용할 수 있습니다 게시물 ACF를 사용하는 경우 나 너무 베어 디자이너는. 어떤 도움

답변

1

greatful 될 것이다, 그러나 당신이 사용하는 경우 분류법, 사용자 또는 옵션과 같은 다른 항목을 사용하는 경우 ACF는이를 찾는 방법에 대한 힌트를 제공해야합니다.이 경우에는 어떤 분류 및 용어를 구체적으로 타겟팅해야 하는지를 알려야합니다. 다행스럽게도 WordPress와 ACF 모두 정말 쉽습니다.

//Ask WordPress for the currently queried object 
//http://codex.wordpress.org/Function_Reference/get_queried_object 
$obj = get_queried_object(); 

//Pass that object as a second parameter into get_field 
$destination_landing_image = get_field('destination_landing_image', $obj); 
+0

나는 더 빨리 알았 더라면 환상적입니다! – ivordesign

관련 문제