Support

Account

Home Forums Front-end Issues Remove 'http://' from text fields Reply To: Remove 'http://' from text fields

  • Using the get_field(); function you can store data in a variable.
    http://www.advancedcustomfields.com/resources/get_field/

    So let’s say the text box value is “http://example.com/” stored in a field called ‘url’.

    First, we grab this value.
    $site = get_field('url');

    Then replace the http:// or https://
    $site = str_replace(array('http://', 'https://'), '', $site);

    Then we remove the trailing slash.
    $site = rtrim($site, '/');

    Finally, echo the value.
    echo $site;