2014-08-28 137 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(),你是任何帮助,将不胜感激

回答

1

,但是当你用它与任何其他的分类法,用户或选项一样,你需要给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 2014-08-28 13:22:26

相关问题