Is it possible to make a search-replace query on WP programmatically without any other plugins (I already know about “Better search replace” and other ones available, but it’s not the option).
Succinctly, yes – the existence of “Better Search and Replace” is a testament to the possibility.
A search-and-replace by itself is simple – you can make the necessary SQL queries through the WPDB interface. The complexity in writing such a thing from scratch lies in whether or not that operation needs to affect fields which WordPress serializes, as performing a replacement in serialized data without unserializing and reserializing the string or otherwise updating the serialization will invalidate the data.
If using a pre-made plugin is not an option, studying such a plugin’s code to see how they accomplish that feat would be a good move.
Related Posts:
- Post meta vs separate database tables
- How do I create a custom role capability?
- Is it mandatory to use $wpdb->prefix in custom tables
- Update Option Stored in Multi-Dimensional Array
- Prevent network activation of plugin
- Uninstall script for a plugin in Multisite
- Changing Plugin Load Order
- Using a database view = evil incarnate?
- Writing a plugin that notify my friends of new post that mentions(@) them
- WordPress and multithreading
- How to Get a List of Sub Blogs without Using get_blog_list()?
- What is the correct way for plugins to create tables with special charset/collation considerations?
- Error getting correct blog_id on MU from functions.php
- Actions or filters fired when data is saved in a custom table
- WordPress multisite apply different options over each site from same plugin
- Only allow plugin to be activated on root site of multisite
- How to use wp_set_password in a plugin?
- WordPress Media mime type filter problem 4.0
- Sample — test — data for large WordPress install
- Custom Plugin Database relations
- Is there any reason only 1 (my) IP would be added to this table using $wpdn->insert?
- How to store data for posts/pages built with drag-n-drop builder?
- Database for development
- What is the best way to overwrite /wp-admin/ms-delete-site.php
- Is there a naming convention for database tables created by a plugin?
- Where should I store global data for my multi-site WordPress plugin?
- unable to stop loop when using wp_insert_post with publish_post hook
- Customize multisite site creation with user data
- how to activate plugin network-wide, and save setting across sites
- Version upgrade: can my plugin filter the SQL statements issued during a database upgrade?
- Saving data from block editor to the database
- What is difference between blog id and site id?
- Creating table with plugin is not working
- How to create a Tools menu on the Network Admin dashboard from a plugin
- dbDelta() Error – Incorrect index name ” for query ALTER TABLE
- Update/insert only a column of database table
- Subscribe to author?
- How to associate an existing user to a site in a multisite setup programmatically
- How To Change Post Author Default?
- How should I store a log for my plugin
- Using WPDB to output raw XML fails because of wp-blog-header.php
- Plugin menu addition in multisite
- Strange issue saving custom field data for a WooCommerce order
- What should happen when a WordPress Plugin is activated across the network (Network Wide Activation)
- How to perform a heavy and long process in cron jobs?
- Form doesnt save to database
- Updating Woocommerce Settings API when WordPress Settings API saved and vise versa
- Multiple Plugin best practice in Multisite
- Is using custom table to suit business needs instead of transients a big hit to page load speed?
- Plugin Development for registered users
- Selectively update themes in WordPress multisite
- Optimising a big WordPress site
- wpdb->prepare and mysql UPDATE – how is it done?
- dbDelta SQL Query Not Working
- how to invoke wordpress API from other existing PHP system
- WP Multisite login not working on one subsite. Possibly cookies/ history issue?
- dbDelta not installing database
- Is it necessary to do validation again when retrieving data from database?
- register_activation_hook on multisite
- Plugin: database creation
- Adding columns to core tables
- Show dynamic list of products from custom api of another database under same host
- Make Database query only when option is updated
- Can we intercept user_login and user_pass from a wp_login_form?
- How best to handle database version dependence (from $wp_db_version)
- Using AND and bracket grouping in SQL not working
- How to get current logged-in user details in multisite?
- Plugin Development: Storing and Manipulating Data That Fits JSON in Database
- add_action wp_ajax_ not loading in plugin file WP Network
- What might be the reason of Couldn’t fetch mysqli_result on another domain?
- Clean way to initialize plugin in newly-added site when plugin has been network activated?
- Save temporary registration data
- $wpdb->update Issue
- Is there anything special required to make a plugin work in a multisite environment?
- How to edit wp-signup.php content using plugin
- dbdelta failing with error: “WordPress database error Table ‘wp_2_myPlugin’ already exists
- Why User_login key doesn’t work with wp_update_user()
- WordPress how do I echo SUM from a column of a MySQL table by user id AND type_operation
- How do I ensure I can loop through every enqueued script and CSS?
- WordPress Fatal error: Uncaught Error: Call to undefined function dbDelta()
- Custom Plugin activation error in Multisite
- Replace “content-area” of themes 404 page with plugin?
- Relational / Associate tables using native WordPress functionality
- WordPress doesn’t create table on plugin activation
- Insert Data into Database
- Update database record in plugin
- pull data from wordpress database
- Same header/footer in Admin, across all network sites in multisite
- Why Worpdress doesn’t create table in database?
- Form and database, plugin development
- How to filter get_adjacent_post()?
- Post data in wp-admin to external database
- Change Admin menu placement using hooks
- How can I get a plugin to hook ‘dbdelta_queries’ — a filter used during version update?
- Running one-off cron jobs when WP_DISABLE_CRON is true: can I hit /wp-cron.php?
- How to create a database table in WordPress using PHP
- Can I log the searches that are returning 404 in the DB?
- Programmatically creating posts based on external JSON feed (asynchronously)
- Making a user platform reachable by a qr code on a pin-back-button [closed]
- multiple record insert creating many duplicate records