• Resolved enthuswdeveloper

    (@enthuswdeveloper)


    I have a wordpress website that accesses a web service. I have 2 environments and the web service url is different in each. I would like to call the right webserice url via configuration instead of hard coding the url in my wordpress php files. How can I configure webservice Url in wp-config.php file and how can I get the URL information in my theme php files.

    Note: I prefer not using any plugins to achieve this.
    Thanks,

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    You could add a define to wp-config.php — something like

    define( 'WEB_SERVICE_URL_1', 'https://weburl.com' );

    then in your code do something like

    if ( defined( 'WEB_SERVICE_URL_1' ) ) {
       // do something with that url
      } else {
       // fail gracefully
      }

    Note that you’d need to add a est to make sure that the constant is a properly defined URL, etc.

    Thread Starter enthuswdeveloper

    (@enthuswdeveloper)

    Thank you very much Steve Stern for your input. Your input/suggestion worked for me.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘configuring web service url in wordpress’ is closed to new replies.