How can I dynamically set the base URL of an ACF custom URL field?

Add the following code to dynamically set the base URL for your ACF custom URL field.

Replace slide_url with the name of your ACF custom URL field

function custom_acf_slide_url_base_url($value, $post_id, $field) {
    // Get the base URL dynamically based on the environment
    $base_url="";
    if (strpos(site_url(), 'staging') !== false) {
        $base_url="https://staging.example.com"; // Replace with your staging URL
    } else {
        $base_url="https://www.example.com"; // Replace with your production URL
    }

    // Append the relative path to the base URL
    $slide_url = $base_url . '/my-page';

    return $slide_url;
}

add_filter('acf/load_value/name=slide_url', 'custom_acf_slide_url_base_url', 10, 3);

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş