One option is setting the site’s URL in the wp-config.php
file itself. This effectively overrides the siteurl
option that’s otherwise stored in the database, but it also means you can reference the URL without doing a query.
From the Codex:
It is possible to set the site URL manually in the wp-config.php file.
Add these two lines to your wp-config.php, where “example.com” is the correct location of your site.
define('WP_HOME','http://example.com'); define('WP_SITEURL','http://example.com');
After that, using code in a regular theme that checks the siteurl
or home
option will pull from the constant rather than the database (hence my note on the override above). But in your default error script, you can reference WP_SITEURL
directly to build a redirect URL.
Related Posts:
- Count & Display Database Queries
- How to monitor server for error establishing a database connection
- Where are WP_Errors Saved
- Redirecting to old domain after migration website
- A change in URL slug in database returns 404, how can I do auto-redirect?
- How to get the full stack trace for WordPress “table doesn’t exist” error in debug.log?
- After Migration From dev, Only my Links to the Homepage Still Redirect to dev
- Send data to database after redirect (and popping out of iframe)
- Redirect Issue: WordPress database
- Homepage redirects to other site of mine? [closed]
- Difference between partition key, composite key and clustering key in Cassandra?
- How SID is different from Service name in Oracle tnsnames.ora
- What is a relation in database terminology?
- Why WordPress choose data serialization over json_encode?
- Relaunch 4.2 utf8mb4 database upgrade
- Reset Post IDs to less than 64bit integer
- Where can I find the database changes between WordPress versions?
- Does WordPress use the InnoDB engine for MySQL by default?
- $wpdb->prepare() warning in WordPress 3.5
- When is it appropriate to create a new table in the WordPress database?
- Best way to import users, post and categories from an external database
- Performance tips for a large user base [closed]
- How to delete outdated, wrongly sized images in _wp_attachment_metadata?
- Prevent changing the length of post_name column on WordPress Update
- Why does dbDelta() not catch MysqlErrors?
- Migrate a Non WordPress database to wordpress [closed]
- Moving an entire wordpress site from one domain to a new domain and database
- how to transfer wordpress sql/database from local to live
- Custom DB_COLLATE (collation) value not working on fresh install?
- What causes the “max_user_connections” warning on WordPress frontend?
- Get Database Credentials from within the themes file
- what to do when your WordPress database is too large?
- How does WordPress create its database during installation?
- WordPress DB: options-table –> 32 gzipcompression?
- Subscribers to posts
- $wpdb->update has finished saving trigger?
- Having issues with wp_postmeta and wp_usermeta tables too big
- WordPress site uses MyISAM, should I switch to InnoDB necessary?
- WP Database Table to CSV file
- How can I UN-orphan media files?
- Does WordPress always create unique passwords?
- Uppercase to sentence case for post titles
- How to retrieve and show database table in wordpress dashboard
- Merge two WordPress installations into one, and keep posts separated?
- Moving online website to MAMP or dumb idea?
- Storing data for a wordpress plugin
- WordPress database import: Row size too large
- Advanced SELECT query with condtional statements
- WordPress choose wrong database
- How can I (semi) automate a database export and import to a different location?
- Improve performance by removing unnecessary database queries
- Localhost keeps redirecting to live domain
- Unable to set a default serialized array using dbdelta()
- How to get nav_menu_item_id and slug from wp database
- Is there a way to execute a php script outside WordPress?
- Make changes of wp-db.php file persistent against updates
- How can I restrict php mail() to only send me one email after a db error
- Change the default data installed when setting up WordPress
- How to delete post comments from the database via SQL statement?
- Why does changing Database Table Prefixes result in loss of content?
- $wpdb->get_var – What value is returned when zero records are found?
- wp_option table error while importing
- SymmetricDS in dev + prod workflow?
- Fixing YARPP plugin FULLTEXT MySQL indexing
- What is wrong here? Issue with post_id and meta_value
- Error establishing a database connection in wordpress site , website not opening
- Counting post and changing roles in mysql database. Query not code
- wpdb Insert unknown post data dynamic foreach loop
- How do I use a database in a custom theme?
- Deleting empty meta key values
- I imported an restore an database and It shows #1067 – Invalid default value for ‘user_registered’
- WP 5.5, child themes, customizer and a weird cache issue
- How do you enable scripts on a WordPress installation in Softaculous?
- How to rerieve comments and their replies from DB
- Inserting data with Geometry field
- Best way to store 1 billion+ posts?
- Export only a part of the database for migration
- Why am I being prompted to reinstall wordpress?
- What’s the easiest way to connect external database and display data on wordpress?
- database error WordPress move from one hosting to other
- Character encoding issue – black diamond question marks on imported post excerpts
- Same DB for live and dev versions
- update multiple user meta field based on another meta field
- After renaming MySQL database, I can no longer access my Blog page
- Reinstall wordpress/mySQL caused database problem
- execute custom function on database connection error
- Call to a member function insert()
- Create a new table on the database and save parameters from a contact form
- not saving post in wp_post wordpress database table
- How to have WP Search widget index dynamically generated content?
- Preventing concurrent update of data
- How to add data from wordpress tables to new database tables you have created
- Creating Tables in WordPress Database
- Calling update_user_meta inside of another function doesn’t work
- How to back-up a database on IIS
- $wpdb->prepare returns empty array
- Prevent creation of unused database tables?
- Where are database files of a WordPress website?
- WP Multisite Users Not Linking
- Query a meta key using an array of values where the database value is a string