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