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
- Default table collation on plugin activation?
- Changing Plugin Load Order
- What is wrong with using add_option with Multisite instead of add_blog_option in a plugin
- Using a database view = evil incarnate?
- Writing a plugin that notify my friends of new post that mentions(@) them
- Getting wrong relationship value in $args in wp_Query?
- WordPress and multithreading
- How to Get a List of Sub Blogs without Using get_blog_list()?
- Not sure the best way to save custom plugin data
- The ideal place for storing persistent PHP objects
- What is the correct way for plugins to create tables with special charset/collation considerations?
- Cron firing my function everytime wp-admin is visited
- Error getting correct blog_id on MU from functions.php
- How do I make specific plugin functionality apply to different sites in a network?
- What is the added “complexity” of custom tables?
- Plugin development with unit tests
- How is the data stored in the database?
- Formatting of curly brackets array from WP database to get more readable output
- How to modify post content before writing to database?
- Actions or filters fired when data is saved in a custom table
- WordPress multisite apply different options over each site from same plugin
- Filters ‘request’ and ‘parse_query’ not firing in sites.php nor link-manager.php
- Multisite, sharing content by URL
- Only allow plugin to be activated on root site of multisite
- Hello dolly type plugin that allows people to add their own
- 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?
- Activation hook not creating table
- Is the usage of ON DELETE CASCADE wrong or not allowed on wordpress?
- 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
- Multisite plugin development and wp_enqueue_script
- Plugin Uninstall and Deactivate via Options Menu
- 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 for the tables ending with the meta used in database of wordpress?
- Sharing a common set of image files for media library, across all sites within multisite
- 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
- Get a custom table to an array
- Override the default Add/Edit site forms of the Network Panel in custom plugin
- How to set “Site Address (URL)” programmatically on WP multisite?
- Update/insert only a column of database table
- How to Create database table when Plugin installed/activated, and delete database when Plugin deleted
- Subscribe to author?
- How to associate an existing user to a site in a multisite setup programmatically
- I’m designing a plugin to create database indexes. Suggestions?
- 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?
- How should I store a log for my plugin
- How to create database table, add data, update and delete using wpdb via plugins?
- Adding (blog-specific) links to “My Sites” admin page
- Using WPDB to output raw XML fails because of wp-blog-header.php
- Are there any scripts, classes, and/or functions built-in to WP for a plugin to export/import its saved data from wp_options?
- 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
- Problem with context in multisite – getting main site data in every blog (get_pages())
- Force remove parent theme CSS/JS and call them from Child theme
- 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
- Leveraging Core Functionality in Icon Upload Plugin [closed]
- Can I log the searches that are returning 404 in the DB?
- Programmatically creating posts based on external JSON feed (asynchronously)
- WordPress database error: [Table ‘bitnami_wordpress.questions’ doesn’t exist]
- Making a user platform reachable by a qr code on a pin-back-button [closed]
- multiple record insert creating many duplicate records
- 2 Domains pointing to SIngle WordPress , issues with links
- Custom Plugin Breaks Other Plugin Functions
- Custom database table entry edit page
- Update Cache on Save Instead of Clearing It?
- Images stored from external API not loading
- Is there a way to force plugins to use Flyway migrations for database changes?