Support

Account

Home Forums Front-end Issues Simple formatting help please

Solved

Simple formatting help please

  • Hi I am new to coding and trying my first wordpress site
    I have created a date-picker custom fieldname: ‘birthdate’
    I have created a taxonomy custom fieldname: ‘qicname’

    <?php the_field(‘birthdate’) ; ?> displays YYYYMMDD (default value)
    <?php the_field(‘qicname’); ?> displays the term_ID2 value, in this case “22” the correct value, but I want the name…

    I have tried to get the syntax correct, but an unable based on ACF examples (I’m missing something fundamental)

    I would like to format birthdate as DDMmmYY
    I would like to return the “tag_name” for the value of term_ID2

    Could you help me with the code?

    Thanks

  • Hi there…

    When you are creating a Date field, you can choose the “display” format, and the “return” format independently… there is a Custom option where you can put the mask you specified above.

    For taxonomy… you can choose a return type of Object, rather than ID.

    Then, to output the taxonomy name, you would do:
    (assuming a ‘single’ choice field like a radio or select button)

    
    <?php
    $term = get_field('qicname');
    if( $term ) {
      echo $term->name;
    }
    ?>
    

    For a multi-choice taxonomy, you would create a loop as shown here:
    https://www.advancedcustomfields.com/resources/taxonomy/

  • Thanks Keith, the context you provided was just what I needed together with the examples…

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

The topic ‘Simple formatting help please’ is closed to new replies.