functions – If ACF field is empty show different value


I have a function setup in my functions.php file which I am trying to use to show a Advanced Custom Field with a fallback value if that field is empty. Here is what I have so far:

add_filter( 'facetwp_map_marker_args', function( $args, $post_id ) {

    $field = get_field( 'Type', $post_id ); // Get this post's ACF value
    $value =   if( $field == true ){ echo $field;} else { echo $tent; };

    $args['icon'] = '' . $value . '.png';
  return $args; }, 10, 2 );

In other words:
If $field has a value then it should be use but if it is empty then it should default to $tent.

moorewebx 2 years 2022-01-25T19:48:35-05:00 0 Answers 0 views 0

Leave an answer