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
- 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
- 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
- How is the data stored in the database?
- Actions or filters fired when data is saved in a custom table
- Multisite, sharing content by URL
- How to use wp_set_password in a plugin?
- WordPress Media mime type filter problem 4.0
- Sample — test — data for large WordPress install
- 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?
- 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
- Plugin Uninstall and Deactivate via Options Menu
- how to activate plugin network-wide, and save setting across sites
- 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
- Override the default Add/Edit site forms of the Network Panel in custom plugin
- Update/insert only a column of database table
- How to Create database table when Plugin installed/activated, and delete database when Plugin deleted
- How to associate an existing user to a site in a multisite setup programmatically
- WordPress Multisite with Azure B2C redirect_urls after Login
- WordPress database error for query INSERT INTO
- How to connect to AWS RDS external database (not for the core WordPress db)
- How To Change Post Author Default?
- Adding (blog-specific) links to “My Sites” admin page
- Using WPDB to output raw XML fails because of wp-blog-header.php
- 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
- Problem with context in multisite – getting main site data in every blog (get_pages())
- Optimising a big WordPress site
- wpdb->prepare and mysql UPDATE – how is it done?
- dbDelta SQL Query Not Working
- register_activation_hook on multisite
- What is the best way to store a few fields?
- Plugin: database creation
- Delete data from database using row action
- Show dynamic list of products from custom api of another database under same host
- How do I have now a duplicated user entry if this is not allowed (and I cannot replicate it)?
- Alternative functions for mysql_free_result and mysql_ping in wordpress functions
- Make Database query only when option is updated
- WordPress multisite,use same cookies across all website?
- 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
- How do I debug an error that a plugin is causing?
- Save temporary registration data
- Update plugin settings option_name for big plugin update
- Is there anything special required to make a plugin work in a multisite environment?
- WordPress database error: [Query was empty] – using $wpdb->prepare()
- Why User_login key doesn’t work with wp_update_user()
- How to get inserted row IDs for bulk/batch insert with wpdb query?
- WordPress how do I echo SUM from a column of a MySQL table by user id AND type_operation
- Replace “content-area” of themes 404 page with plugin?
- Save in my custom admin page and redirect to the saved object
- Relational / Associate tables using native WordPress functionality
- WordPress doesn’t create table on plugin activation
- Multisite and the JSON REST API: How to?
- Update database record in plugin
- How to store in the database directly the translation?
- Testing Plugins for Multisite
- How and when would I implement some code which would take data from one part of the Db and put it in another?
- Why Worpdress doesn’t create table in database?
- Form and database, plugin development
- Associating special meaning with user id 0
- What method should I use to store my plugin data (multi level menus with options on each item)
- How to add additional field in a table row after creating a table?
- WordPress plugin tables become corrupt
- Change Admin menu placement using hooks
- Force remove parent theme CSS/JS and call them from Child theme
- Running one-off cron jobs when WP_DISABLE_CRON is true: can I hit /wp-cron.php?
- Leveraging Core Functionality in Icon Upload Plugin [closed]
- WordPress database error: [Table ‘bitnami_wordpress.questions’ doesn’t exist]
- multiple record insert creating many duplicate records
- 2 Domains pointing to SIngle WordPress , issues with links
- Custom database table entry edit page
- How to get list of ALL tables in the database?