/**
 * Displays listing fields.
 *
 * @param int $listing_id (optional)
 *
 * @return void
 */
function the_listing_fields( $listing_id = 0 ) {
	$listing_id = $listing_id ? $listing_id : get_the_ID();
	$cats = array_keys( get_the_listing_categories( $listing_id ) );
	if ( ! $cats ) {
		return;
	}
	$fields = array();
	foreach ( $cats as $cat ) {
		foreach ( va_get_fields_for_cat( $cat, VA_LISTING_CATEGORY ) as $field ) {
			$fields[ $field['name'] ] = $field;
		}
	}
	foreach ( $fields as $field ) {
		if ( 'checkbox' === $field['type'] ) {
			$value = implode( ', ', get_post_meta( $listing_id, $field['name'] ) );
		} else {
			$value = get_post_meta( $listing_id, $field['name'], true );
		}
		if ( ! $value ) {
			continue;
		}
		$wrapper = 'span';
		if ( 'textarea' === $field['type'] ) {
			$wrapper = 'div';
			$value = nl2br( $value );
		}
		$field['id_tag'] = va_make_custom_field_id_tag( $field['name'] );
		echo html( 'div', array( 'class' => 'listing-custom-field', 'id' => $field['id_tag'] ),
			html( 'span', array( 'class' => 'custom-field-label' ), $field['desc'] ). html( 'span', array( 'class' => 'custom-field-sep' ), ': ' ) . html( $wrapper, array( 'class' => 'custom-field-value' ), $value ) );
	}
}
There are currently 1 users browsing this thread. (0 members and 1 guests)