Changing siteurl in the database not working

I'm trying to change siteurl and home in the database, but whenever I try to change after 5 seconds they automatically change back to the previous url.

Is it related to the server?

Topic site-url urls Wordpress

Category Web


WordPress has a number of standard methods to change or override these url options:

  • using update_option() function in functions.php or anywhere else in the code, this way: update_option( 'siteurl', 'https://yourdomain.com' );
    update_option( 'home', 'https://yourdomain.com' );
    This is most likely your case because update_option() edits db entries at runtime.
    In this case, just remove or comment out these lines where you find them.
  • using define();
    define( 'WP_HOME', 'https://yourdomain.com' );
    define( 'WP_SITEURL', 'https://yourdomain.com' );
    This only overrides the setting but does not change the entries in the database.

If your url changes in the address bar, but does not change in the database, this may happen due to WordPress caching. Try one of these:

  • edit wp-config.php and add define('ENABLE_CACHE', FALSE);
  • add a query string with an argument to clear cache, i.e. https://yourdomain.com/?x=z
  • if you use CloudFlare or other caching service, clear cache for this url

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.