Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #503370

    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

    #503495

    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

    #503497

    Hi ariane1001!

    Try has_term() instead, http://codex.wordpress.org/Function_Reference/has_term.

    if ( has_term( 'overleden', 'category' )
    

    Cheers!
    Elliott

    #503971

    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

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘use in_category for portfolio items?’ is closed to new replies.