Created
May 11, 2020 22:28
-
-
Save mgibbs189/b9ffa6ea9c4cd732e3238632201ccc06 to your computer and use it in GitHub Desktop.
ACF - set "Other data source" equal to "Data source" if empty
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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