Since you mention multiple environments you can manually define the site URL within your wp-config.php file
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/path/to/wordpress');
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/path/to/wordpress');
Keep in mind that it will override what you have set in your options table. As detailed in the documentation:
Setting this value in wp-config.php overrides the wp_options table value for siteurl and overrides the WordPress address (URL) field in the Administration > Settings > General panel when logging in using wp-login.php. It will not update your Home url.
Related Posts:
- Why does WordPress rely on an fully qualified site_url with a 15-step plan for moving a site?
- I don’t see site_url and home_url fields in wp_options table (phpMyAdmin)?
- Moving Site: Is Re-downloading Files After Changing URLs necessary?
- How to move existing WordPress wp-content folder along with database to new server and new domain name?
- Sub-domain or 2nd, temporary different domain?
- WSOD 3.9.1 – Tried Everything so far
- Is it risky if I update all url in the database due to my site url changed?
- echo site_url() returns a different value than what is in the database siteurl field
- After Migration From dev, Only my Links to the Homepage Still Redirect to dev
- WordPress site seems convinced that it’s still at its old URL
- What is this JavaScript “require”?
- Using wpdb to connect to a separate database
- How can I make updates to a site, on a development copy, but then move updates back without overriding live site’s evolving database?
- get_results using wpdb
- How can I make a WordPress database portable and url independent?
- wpdb->insert multiple record at once
- How to migrate a HTTPS WordPress installation to localhost?
- How to stop WordPress using utf8mb4_unicode_520_ci collation?
- How to monitor server for error establishing a database connection
- Exporting revisions
- WP_Options ID high
- Default WordPress settings API data sanitization
- Fatal error: Call to undefined function dbDelta()
- Connect to remote database using Localhost install
- remove missing image attachments
- How to use multiple database in wordpress?
- How to ensure data consistency in WordPress
- Is removing orphaned wp_postmeta records safe?
- How to intercept update_option() before it saves data?
- wpdb query on custom table not working [closed]
- How to diagnose and keep in check encoding issues?
- Delete all post meta except featured image Using SQL
- WordPress doesn’t show all posts in database
- Adding new row to wp_post table
- Extracting the post_id via the wp_insert_post action (external db query)
- How to interact with another wordpress install on same database?
- Are custom tables in the database overwritten when WordPress is updated to new versions?
- What is the proper way to validate and sanitize JSON response from REST API?
- How do I get the posts within a certain year/date(with sql query)?
- batch UPDATE autoload value in wp_options table
- Displaying BLOB PDF File
- Saving into post_excerpt or post_content
- Maintain user profile data in a non-WordPress database
- How to fix the disappearance of the “\” character when updating a post in the database
- Data storage for JS app using WP REST API
- Update from 4.5 to 4.6 failing
- Setup 3 Sites To Connect To 1 Database and Share Data
- How can I push local database changes to production, without impacting recent posts/pages that were published on production server?
- Setup private content for specific users with daily updates [closed]
- Does auto_load to ‘no’ in wp_options improve performance
- Connection refused on locahost after importing database?
- creating new field on mysql
- Is it possible to rebuild the website while not accesseing the original database?
- Error message on blog posts only on my local environment [closed]
- how to read database fields
- $wpdb->query can’t insert data
- Can you refresh ONLY the wordpress adminbar and not the whole page?
- Sending posts from Python to WordPress
- Problem migrating to localhost
- SQL query to set posts in bulk based on the post content
- Automate WordPress website setup with prefilled data
- How can I detect right db type?
- Add search bar to Custom Database Table in WordPress Dashboard
- Design problems when exporting remote database for local development
- How do you render posts from outside wordpress?
- A change in URL slug in database returns 404, how can I do auto-redirect?
- Second ezSQL initialization for MSSQL
- Fetch a single row from a custom table for to a given ID
- Database create or redirect
- Database structure cheatsheet
- White Screen in Home Page
- Continuous SQL query errors from outside source
- How to escape percentage sign(%) in sql query with $wpdb->prepare?
- Recovery – Restore Database after moving folder location locally
- Migrate Users From laravel to wordpress
- WordPress has been updated! Before we send you on your way, we have to update your database to the newest version
- how add more field to wp user and save it to database
- How do I cleanup my database with data that is no longer being used?
- Malware in old website – how to migrate?
- A WP dev site that displays content from a live site’s database but cannot write to wp_posts?
- error establishing database connection (WAMP + filezilla)
- Is there a way for two deferent themes to consume two different DB on a same WP instance?
- change home_url and site_url but don’t redirect to home_url and site_url on load
- How to display $wpdb->insert_id; value on redirected page
- Should I Use only wpdb Class to Write Custom Queries?
- Auto populate form fields based on serial input or pull listings from other websites?
- How to extract some part of WordPress full source code
- Wrong url for the images while using same database for two WordPress installations
- Error establishing a database connection for some files
- Hash user emails in database?
- Sending WordPress database information to cross domain the safe way?
- Database Name Change
- Weird characters in title if it contain “ ”
- Where To Find bb_profile_data(); In bbPress?
- Saving data to database and exporting to excel
- One information repeated on multiple locations on one site [closed]
- Showing Error(TAble already exist)
- Is there a way to append a trailing slash to get_home_url() and get_permalink( get_option( ‘page_for_posts’ ) )?
- Cant Connect to Database
- WordPress database connection failed, while mysql client is working [closed]