Is it possible to "Update" pages via SQL?

How can I update a page in WordPress using MySQL? I.e., effectively click the update button in the page editor using MySQL? But not make any changes to the page?

What I'm doing: I'm making some bulk changes in wp_postmeta using a MySQL query in PHPMyAdmin, i.e. Woocommerce product data. I've discovered that each page needs to be manually Updated in the page editor for the product data to appear correctly on the front end. Once I make the changes in wp_postmeta, and then wp_update_post resave each page, the data appears correctly.

How can I resave or Update a number of pages, by each post_id, via MySQL so I don't ave to manually save each page? Would I use wp_update_post ? https://developer.wordpress.org/reference/functions/wp_update_post/

I don't need to use Ajax; this concerns ~100 pages and the server is fast, so an SQL query won't timeout.

Topic wp-update-post Wordpress

Category Web


wp_update_post() is a PHP function, and you can’t trigger a page update with MySQL. You need to at least use PHP, but it’s possible that some plugins actually require manually pressing update.

For WordPress and WooCommerce content your best bet would be to use the REST API or WP CLI from the command line.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.