I need to have the value of a custom field in the functions.php file. This what I already have. I can get the value on a page template, but in this case it is need in the functions.php file because I need that value in the facewp function.
add_filter( 'facetwp_preload_url_vars', function( $url_vars ) {
$offer_id = get_field('offer_type'); // need this value from the current page
$term = get_term( $offer_id, 'offer' ); // offer = tax slug
$slug = $term->slug;
if ( empty( $url_vars['offer_type'] ) ) {
$url_vars['offer_type'] = [$slug];
}
return $url_vars;
} );
How can I achieve this? Now I'm getting an empty variable.