Last active
December 14, 2023 22:36
-
-
Save Acephalia/66c02add6f7df5cf3a06542b9a7168b7 to your computer and use it in GitHub Desktop.
Remove/replace "https://" from ACF URL field output
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
// Remove "https://" from ACF URL field output | |
function sanitize_acf_url_output($value, $post_id, $field) { | |
if ($field['type'] === 'url') { | |
// Remove "https://" from the URL | |
$value = str_replace('https://', '', $value); | |
} | |
return $value; | |
} | |
add_filter('acf/format_value/type=url', 'sanitize_acf_url_output', 10, 3); |
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
// Replace "https://" with "www." in ACF URL field output | |
function modify_acf_url_output($value, $post_id, $field) { | |
if ($field['type'] === 'url') { | |
// Replace "https://" with "www." | |
$value = str_replace('https://', 'www.', $value); | |
} | |
return $value; | |
} | |
add_filter('acf/format_value/type=url', 'modify_acf_url_output', 10, 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment