Wp search-replace(WP-CLI)

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen
Voorbeeld wp search-replace waarbij siteurl en home worden aangepast - Oude situatie
Voorbeeld wp search-replace waarbij siteurl en home worden aangepast - Nieuwe situatie

wp search-replace vervangt strings in de database. Kan handig zijn rondom migraties.

Syntaxis

wp search-replace <old> <new> [<table>...] 
   [--dry-run] 
   [--network] 
   [--all-tables-with-prefix] 
   [--all-tables] 
   [--export[=<file>]] 
   [--export_insert_size=<rows>] 
   [--skip-tables=<tables>] 
   [--skip-columns=<columns>] 
   [--include-columns=<columns>] 
   [--precise] 
   [--recurse-objects] 
   [--verbose] 
   [--regex] 
   [--regex-flags=<regex-flags>] 
   [--regex-delimiter=<regex-delimiter>] 
   [--format=<format>] 
   [--report] 
   [--report-changed-only] 
   [--log[=<file>]] 
   [--before_context=<num>] 
   [--after_context=<num>]

Als het niet lukt om te connecten met een database middels de gegevens in wp-config.php, krijg je een foutmelding.

Welke tabellen & velden?

Dit commando vervangt niet in alle tabellen, maar in specifieke tabellen en in specifieke velden. Zie [1] voor details. Een indicatie (met de optie --dry-run van de tabellen en velden waar dit commando standaard actie op onderneemt:

+----------------------------------+-----------------------+--------------+------+
| Table                            | Column                | Replacements | Type |
+----------------------------------+-----------------------+--------------+------+
| wp_actionscheduler_actions       | hook                  | 0            | SQL  |
| wp_actionscheduler_actions       | status                | 0            | SQL  |
| wp_actionscheduler_actions       | args                  | 0            | SQL  |
| wp_actionscheduler_actions       | schedule              | 0            | PHP  |
| wp_actionscheduler_actions       | extended_args         | 0            | SQL  |
| wp_actionscheduler_groups        | slug                  | 0            | SQL  |
| wp_actionscheduler_logs          | message               | 0            | SQL  |
| wp_commentmeta                   | meta_key              | 0            | SQL  |
| wp_commentmeta                   | meta_value            | 0            | SQL  |
| wp_comments                      | comment_author        | 0            | SQL  |
| wp_comments                      | comment_author_email  | 0            | SQL  |
| wp_comments                      | comment_author_url    | 0            | SQL  |
| wp_comments                      | comment_author_IP     | 0            | SQL  |
| wp_comments                      | comment_content       | 0            | SQL  |
| wp_comments                      | comment_approved      | 0            | SQL  |
| wp_comments                      | comment_agent         | 0            | SQL  |
| wp_comments                      | comment_type          | 0            | SQL  |
| wp_links                         | link_url              | 0            | SQL  |
| wp_links                         | link_name             | 0            | SQL  |
| wp_links                         | link_image            | 0            | SQL  |
| wp_links                         | link_target           | 0            | SQL  |
| wp_links                         | link_description      | 0            | SQL  |
| wp_links                         | link_visible          | 0            | SQL  |
| wp_links                         | link_rel              | 0            | SQL  |
| wp_links                         | link_notes            | 0            | SQL  |
| wp_links                         | link_rss              | 0            | SQL  |
| wp_options                       | option_name           | 0            | SQL  |
| wp_options                       | option_value          | 14           | PHP  |
| wp_options                       | autoload              | 0            | SQL  |
| wp_postmeta                      | meta_key              | 0            | SQL  |
| wp_postmeta                      | meta_value            | 16167        | PHP  |
| wp_posts                         | post_content          | 5            | PHP  |
| wp_posts                         | post_title            | 0            | SQL  |
| wp_posts                         | post_excerpt          | 0            | SQL  |
| wp_posts                         | post_status           | 0            | SQL  |
| wp_posts                         | comment_status        | 0            | SQL  |
| wp_posts                         | ping_status           | 0            | SQL  |
| wp_posts                         | post_password         | 0            | SQL  |
| wp_posts                         | post_name             | 0            | SQL  |
| wp_posts                         | to_ping               | 0            | SQL  |
| wp_posts                         | pinged                | 0            | SQL  |
| wp_posts                         | post_content_filtered | 0            | SQL  |
| wp_posts                         | guid                  | 16456        | SQL  |
| wp_posts                         | post_type             | 0            | SQL  |
| wp_posts                         | post_mime_type        | 0            | SQL  |
| wp_term_taxonomy                 | taxonomy              | 0            | SQL  |
| wp_term_taxonomy                 | description           | 0            | SQL  |
| wp_termmeta                      | meta_key              | 0            | SQL  |
| wp_termmeta                      | meta_value            | 0            | SQL  |
| wp_terms                         | name                  | 0            | SQL  |
| wp_terms                         | slug                  | 0            | SQL  |
| wp_usermeta                      | meta_key              | 0            | SQL  |
| wp_usermeta                      | meta_value            | 1            | PHP  |
| wp_users                         | user_login            | 0            | SQL  |
| wp_users                         | user_nicename         | 0            | SQL  |
| wp_users                         | user_email            | 0            | SQL  |
| wp_users                         | user_url              | 0            | SQL  |
| wp_users                         | user_activation_key   | 0            | SQL  |
| wp_users                         | display_name          | 0            | SQL  |
| wp_wc_product_meta_lookup        | sku                   | 0            | SQL  |
| wp_wc_product_meta_lookup        | stock_status          | 0            | SQL  |
| wp_wc_product_meta_lookup        | tax_status            | 0            | SQL  |
| wp_wc_product_meta_lookup        | tax_class             | 0            | SQL  |
| wp_wc_tax_rate_classes           | name                  | 0            | SQL  |
| wp_wc_tax_rate_classes           | slug                  | 0            | SQL  |
| wp_woocommerce_order_itemmeta    | meta_key              | 0            | SQL  |
| wp_woocommerce_order_itemmeta    | meta_value            | 0            | PHP  |
| wp_woocommerce_payment_tokenmeta | meta_key              | 0            | SQL  |
| wp_woocommerce_payment_tokenmeta | meta_value            | 0            | SQL  |
| wp_yoast_seo_links               | url                   | 0            | SQL  |
| wp_yoast_seo_links               | type                  | 0            | SQL  |
+----------------------------------+-----------------------+--------------+------+
Success: 32643 replacements to be made.