Last active
January 26, 2022 03:48
-
-
Save retlehs/aa47003249623e52b95a3fcd6f69b8fb to your computer and use it in GitHub Desktop.
WP-CLI aliases sync example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
read -r -p "Would you really like to reset your development database and pull the latest from production? [y/N] " response | |
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then | |
wp @development db reset --yes && | |
wp @production db export - > sql-dump-production.sql && | |
wp @development db import sql-dump-production.sql && | |
wp @development search-replace https://example.com https://example.dev | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
path: web/wp | |
@production: | |
ssh: [email protected]/srv/www/example.com/current | |
@development: | |
ssh: [email protected]/srv/www/example.com/current |
I would guess because the WordPress editor inserts the site URL when adding internal links and img tags. So you have to change those strings in the post_content field for every post.
Those URLs also exist in the wp_options table, which is from where all the WordPress core functions get them (I'm mostly sure). You could use the wp-config constants in your own themes and plugins, but other plugin devs will still use them. ..Although I suppose you could hook into those functions and switch them to pull from the constants. But you'd still have the post_content problem.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've always been a bit fuzzy on this, why use the search-replace on the sites url when it's much easier to just set WP_HOME and WP_SITEURL in the wp config