Tagged: portfolio category
Hi,
I am using enfold and Advanced Custom Fields.
I would like this code to work on portfolio categories:
<?php
if ( in_category( ‘overleden’ )) {
?>
<p>Overlijdensdatum: <?php the_field(‘uitzet_overlijdensdatum’); ?></p>
<?php
} else {
?>
<p>Uitzetplaats en -datum: <?php the_field(‘uitzetplaats’); ?>, <?php the_field(‘uitzet_overlijdensdatum’); ?></p>
<?php
}
?>
The code ignores in_category( ‘overleden’ )
what syntax do I need to use for portfolio categories?
Thanks,
Ariane
I worked a little further with it:
<?php endif; ?>
<?php
if ( in_category( ‘overleden’ )) {
?>
<p><b>Overlijdensdatum:</b> <?php the_field(‘uitzet_overlijdensdatum’); ?></p>
<?php
} elseif ( in_category( ‘uitgezet’ )) {
?>
<p><b>Uitzetplaats en -datum</b>: <?php the_field(‘uitzetplaats’); ?>, <?php the_field(‘uitzet_overlijdensdatum’); ?></p>
<?php
}
?>
Weird thing is, sometimes it works, sometimes it doesn’t.
I’ll give credentials and location below, if you want to take a look.
Thanks Ariane
Hi ariane1001!
Try has_term() instead, http://codex.wordpress.org/Function_Reference/has_term.
if ( has_term( 'overleden', 'category' )
Cheers!
Elliott
Hi Elliot,
Thanks for the help, it was nearly good.
categories in portfolio are not ‘category’ but ‘portfolio_entries’
so when I changed the code to has_term( ‘overleden’, ‘portfolio_entries’ ) it worked.
Cheers Ariane