0

If my website changes domain or protocol, the entire code base does not have to be updated. That is my desired result. More specifically, I want to add a php function to my child theme to convert all http requests to https automatically. I was given some docs to get started but I realize I have too many questions at this point. Can someone help me out?

Cheers BJ

https://codex.wordpress.org/Function_Reference/get_page_by_path

https://developer.wordpress.org/reference/functions/get_permalink/

1

Normally you never have to use your domain in your php code for plugins / themes. There are many functions like get_home_url() which automatically fetches the domain from configuration and is also protocol agnostic if you don't force a protocol via the third parameter $scheme.

The function get_home_url() internally uses is_ssl() and the option value for home to decide which protocol to use.

  • Is <?php echo get_home_url(); ?> sufficient to make the changes I want or would I have to write more code? – Alt-Rock Ninja Dec 18 '16 at 21:56
  • In many cases get_home_url() or get_permalink() (which internally also uses get_home_url() via home_url()) will be enough as long as they yield the url you are looking for. But that depends a lot from use case to use case, so without insight to your code we can't help more thouroughly. – JHoffmann Dec 20 '16 at 0:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.