Home Forums General Issues Custom field display on "php if" variable Reply To: Custom field display on "php if" variable

  • Hi guys I think I figured it out while tinkering last night.
    What I’ve done is add the summary field as a required entry for posts in the Reviews category (does ACF also apple that to subcategories in that main category?) by setting the rules as
    Post category > is equal to > Reviews
    and added this code to my page:

    <?php if( get_field( "review_summary" ) ): ?>
    <h3><?php _e('Summary'); ?></h3>
    <p><?php the_field( "review_summary" ); ?></p>
    <?php endif ?>

    From what I see it seems to be working. If you guys notice that isn’t going to achieve what I’m looking for please let me know, or if the echo code above is a better choice. I tried that code and it didn’t put the proper h3 text style on the title.

    But from what I can see it adds the summary field and h3 title only to posts that have something in the summary field. Is that right? Or is it trying to display it regardless, just without content? I guess that wouldn’t make sense because the title Summary would show up if that were the case.