Wordpress 如果使用ACF Pro显示标题图像,则显示存档页面的错误图像

Wordpress 如果使用ACF Pro显示标题图像,则显示存档页面的错误图像,wordpress,if-statement,advanced-custom-fields,Wordpress,If Statement,Advanced Custom Fields,我试图根据用户访问的页面显示不同的标题图像。除了is_归档文件外,下面的代码非常有用 出于某种原因,它希望使用来自is_archiveteam的图像 <div class="header-images"> <?php if (is_archive('team')) { ?> <img src="<?php the_field('header_image_team', 'options'); ?>" class="img-responsive bkg

我试图根据用户访问的页面显示不同的标题图像。除了is_归档文件外,下面的代码非常有用

出于某种原因,它希望使用来自is_archiveteam的图像

<div class="header-images">
   <?php if (is_archive('team')) { ?>
<img src="<?php the_field('header_image_team', 'options'); ?>" class="img-responsive bkg" />

   <?php } elseif (is_singular('team')) { ?>
<img src="<?php the_field('header_image_team', 'options') ?>" class="img-responsive bkg" /> 

   <?php } elseif (is_archive('listings')) { ?>
<img src="<?php the_field('header_image_listings', 'options'); ?>" class="img-responsive bkg" />

   <?php } elseif (is_singular('listings')) { ?>
<img src="<?php the_field('header_image_single') ?>" class="img-responsive bkg" />

   <?php } elseif (is_home()) { ?>
<img src="<?php the_field('header_image_ic', 'options') ?>" class="img-responsive bkg" /> 
   <?php } ?>

清单前面的elseif语句中也缺少一些分号。也许这就是你的问题

使用正确的语法:

<?php } elseif (is_singular('team')) { ?>
<img src="<?php the_field('header_image_team', 'options'); ?>" class="img-responsive bkg" /> 

如果您没有archive.php或achive-your_custom_post.php,Wordpress将使用index.php显示页面

然后,如果你看不到正确的图像,这是正常的。
因为你在这个例子中是家。

对不起,但是把那些分号加回去并不能解决任何问题。嗯,好的。据我所知,您的选项页代码中一定有一个bug。通读ACF文档,它看起来不错。我已经在我的原始帖子中添加了选项页面代码功能。我觉得一切都很好。也许你看到了一些我没有看到的东西。我有两个存档页面,分别是“团队”和“列表”。这就是我在那些自定义post-type归档页面上显示图像的方式。
<?php } elseif (is_singular('team')) { ?>
<img src="<?php the_field('header_image_team', 'options'); ?>" class="img-responsive bkg" />