Home Forums General Issues Prepend/append text using acf field shortcode?


Prepend/append text using acf field shortcode?

  • Hi all, newbie question incoming:
    I’m using ACF for measurements, and currently outputing these like so on frontend (WooCommerce):
    Lenght: [acf field="lenght"] cm
    Width: [acf field="width"] cm
    Depth: [acf field="depth"] cm
    Height: [acf field="height"] cm

    But most products only have 2 or 3 of these fields, so you end up with half-empty lines like “Height cm”.

    What is the best way to go about hiding the entire lines where there is no data?

  • Can you not use conditional code like:

    $length = get_field('length');
    if( $length ):
      echo 'Length: '.$length.' cm';

    Repeat for each field

  • Thanks a lot, it’s exactly what I was hoping for 🙂

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

You must be logged in to reply to this topic.