Skip to main content

wp_siteurl in config

In WordPress, WP_SITEURL is a constant that can be defined in the wp-config.php file to specify the WordPress address (URL). This constant determines the location of your WordPress core files and is used by the site_url() API function.
Purpose of WP_SITEURL in wp-config.php:
  • Overrides database value: 
    When defined in wp-config.phpWP_SITEURL takes precedence over the siteurl value stored in the WordPress database's wp_options table.
  • Reduces database calls: 
    Setting this constant can potentially reduce the number of database queries required to retrieve the site URL during page loads.
  • Temporary URL changes: 
    It is particularly useful for temporarily changing the WordPress address, such as during site migration or troubleshooting when you cannot access the WordPress admin dashboard.
  • Previewing on temporary domains: 
    Allows previewing a site on a temporary domain without altering the database, preventing redirection to the old server.
How to define WP_SITEURL:
  • Access wp-config.phpConnect to your server using FTP or your hosting provider's file manager and locate the wp-config.php file in your WordPress installation directory.
  • Edit the file: Open wp-config.php in a plain text editor.
  • Add the definition: Add the following line before the line that says /* That's all, stop editing! Happy publishing. */: 
Code
    define('WP_SITEURL', 'http://yourdomain.com');