Why does WordPress rely on an fully qualified site_url with a 15-step plan for moving a site?

This question has been discussed several times on the WordPress Hackers email list, I’d recommend Googling something like wp-hackers absolute relative to get an overview of the various lively debates that have taken place over the years. Personally I use the searchreplacedb2 script whenever I migrate a database between URLs, e.g. from live to local/test/dev.

How to do a MySQL dump from production site without using a search and replace script for local development?

What you posted will work fine for all links that are generated by WordPress: permalinks, script/style enqueues for local files, featured images, etc. I tend to define my Site URL and Home URL dynamically like this: <?php define(‘WP_HOME’, ‘http://’ . $_SERVER[‘HTTP_HOST’]); define(‘WP_SITEURL’, WP_HOME . ‘/wp’); Note: HTTP_HOST isn’t always present, use with caution As far … Read more

MySQL LIKE not working

Try to replace: AND meta_value LIKE %s with AND meta_value LIKE ‘%%%s%%’ so your SQL will become: AND meta_value LIKE ‘%The%’ instead of: AND meta_value LIKE ‘The’

Search and replace in post content

Okay, this always seems to happen to me. I spend ages looking for an answer and finally decide to give up and post here and then one more search finds enough to solve it. Anyway, this is what worked for me: update wp_posts set post_content = replace(post_content, ‘[/tab] [tab title=”1024×576″] <table class=”screenshot-table”>’, ‘[tabby title=”1024 x … Read more

Usage of Direct Database Call Without Caching Error

I agree with @Tom J Nowell: I’d suggest you remove it, or better yet just say “all rights reserved”. But in the quest for answers, here’s a suggestion using an option field to cache the years: /** * Get year range for posts. * * @return str */ function wpse_226627_get_copyright() { if ( ! $years … Read more

Using two different DB users on one WP install

I have setup WP instance with 2 different database, one for read only and other for admin purpose. But once the admin make the changes, then the ADMIN-DB should be copied and added to SLAVE-DB server. // check if url contains wp-login or wp-admin and then create DB configuration for Master DB else Slave DB. … Read more