Home > front end >  Replace a specific text value after call home_url
Replace a specific text value after call home_url

Time:03-27

I just started the coding and can't figure this out by myself. Plese help.

example in wordpress

<input type="text" name="old" value="<?php echo home_url(); ?>" />

printing- https://example.com

Change printing value = http://example.net

Is it possible to change the printing value after calling the home_url in PHP without Jquery?

Thank you!

CodePudding user response:

Use str_replace function inline; The home_url() return value to str_replace as input, then this function replace com to net, as you need.

<input type="text" name="old" value="<?php echo str_replace('com','net',home_url()); ?>" />
  • Related