Support

Account

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;
    }