Home › Forums › General Issues › Page Link, Archive, Absolute URL › Reply To: Page Link, Archive, Absolute URL
I have one site where I have this issue because I have 3 dev/staging/testing sites with different domain names. In my case I created an filter. All of the domain names include “company-name.com” so I am able to only effect links if they contain the this value.
https://www.advancedcustomfields.com/resources/acf-format_value/
add_filter('acf/format_value/type=page_link', 'remove_domain_from_page_link', 20, 3);
function remove_domain_from_page_link($value, $post_id, $field) {
if (stripos($value, 'company-name.com') === false)) {
// value does not contain company-name.com
return $value;
}
$value = preg_replace('#^https?://[^/]*#', '', $value);
return $value;
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.