Skip to content

Instantly share code, notes, and snippets.

@mgibbs189
Created May 11, 2020 22:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgibbs189/b9ffa6ea9c4cd732e3238632201ccc06 to your computer and use it in GitHub Desktop.
Save mgibbs189/b9ffa6ea9c4cd732e3238632201ccc06 to your computer and use it in GitHub Desktop.
ACF - set "Other data source" equal to "Data source" if empty
<?php
// Add to your (child) theme's functions.php
add_filer( 'facetwp_acf_display_value', function( $value, $params ) {
if ( ! empty( $params['facet_name'] ) ) {
$facet = FWP()->helper->get_facet_by_name( $params['facet_name'] );
if ( ! empty( $facet['source_other'] ) && empty( $value ) ) {
$value = $params['facet_value'];
}
}
return $value;
}, 20, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment