samedi 10 octobre 2015

IF ELSE header images with ACF Pro, showing wrong image for archive page

I'm attemptin to show different header images based on the page a user visits. The code below works great except for is_archive(listings)

For some reason it wants to use the image from is_archive(team)

<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 } ?>

For what it's worth, I am using this with Advanced Custom Fields PRO. So I've setup an options page for the custom post types: team & listings. In each post types menu there is a settings panel with the ability to upload an image.

The singular 'listings' pull an image from each post and then of course is_home (the default blog) has an options panel with an image to upload as well.

Overall, If I am not declaring that the archive page for 'listings' is suppose to show the team image, then it shouldn't show anything all, right?

Aucun commentaire:

Enregistrer un commentaire