Support

Account

Home Forums Front-end Issues Display text depending on category

Helping

Display text depending on category

  • Hello,

    I’ve inherited a site that’s using ACF to display links in a custom post type. Here’s the current part of the template that works just fine.


    <?php if(get_field( "resource_file_name" ) != ''):?> " target="_blank">See More
    <?php elseif(get_field( "resource_link" )):?> " target="_blank">See More<br>
    <?php endif; ?>

    What I would like to change is if the category is News, the button text would say SEE MORE. If the category is Resources, the button text would say DOWNLOAD.

    My PHP skills are limited. I’ve tried using if(has_term… but I think I’m using too many conditionals (or using them incorrectly), and the page breaks.

    The site has already been built with hundreds of pages, so I’m not sure building the custom fields differently is an option at this point.

    Any help or guidance would be much appreciated.

    Thank you

  • The solution was staring me in the face, but I just didn’t see it.

    For anyone with a similar problem, I just had to change the link text of the resource_file_name field to DOWNLOAD.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.