Created
December 14, 2021 18:34
-
-
Save BhargavBhandari90/1608cfecc56a4db3a966c03a900f851d to your computer and use it in GitHub Desktop.
ACF get custom setting.
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 | |
/** | |
* Get custom settings. This works for group type field only. | |
* | |
* @param string $tab | |
* @param string $field | |
* | |
* @return void | |
*/ | |
function acf_get_custom_setting( $tab, $field ) { | |
// Prevent unnecessary function execution. | |
if ( ! function_exists( 'have_rows' ) || empty( $field ) || empty( $tab ) ) { | |
return; | |
} | |
$value = ''; | |
// Get field value. | |
if ( have_rows( $tab, 'option' ) ) { | |
while ( have_rows( $tab, 'option' ) ) { | |
the_row(); | |
$value = get_sub_field( $field ); | |
} | |
} | |
return $value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment