One disadvantage of using that SQL query is that the slug will only be updated when you really go edit the post. Plus, it might cause odd behavior when any plugin tries to do something with an empty slug.
A good alternative would be to use WP-CLI instead.
First, you’ll need a list of all pending posts:
wp post list --post_type=post --post_status=pending --format=ids
Next, you need a way to remove the slug of a post:
wp post update <id> --post_name=""
Now you can combine these commands like this:
wp post update $(wp post list --post_type=post --post_status=pending --format=ids) --post_name=""
This way, the post update will happen through WordPress’ internal API instead of just SQL.
Related Posts:
- is it possible to get a list of URLs from post_content directly in a mysql query via phpadmin?
- simple sql query on wp_postmeta very slow
- How many WordPress SQL Queries per page?
- Multipart/formatted MySQL query problem
- Are database queries created using WordPress filters protected from SQL injection?
- How Do I Merge Categories With phpMyAdmin
- Grouping related postmeta data via SQL query
- $wpdb->query() vs. $wpdb->get_results() vs. phpMyAdmin
- Mysql / WordPress killing my server with 80k users [closed]
- Slow meta_query with about 4 milion record on wp_postmeta
- Select User by Joining Multiple Meta Value Results
- mySQL query. ORDER BY meta_key
- My SQL function to change user_name
- You have an error in your SQL syntax – Help with query
- MySQL variable in query
- how would I create a custom query to get all users, and a related post based on a postmeta field?
- Help with MySQL to $WPDB query
- SQL query to select posts from multiple categories
- How do I see the mysql query generated by get_posts( $args )?
- Alter query with posts_clauses to retrieve NULL values last
- MySql Query very slow
- Searching With Apostrophe
- WordPress Query wp-terms SLOW
- wpdb COALESCE won’t work
- Get posts from category with custom query
- how to insert missing tags into the posts through mySQL?
- Ideas how to search & replace post_content when string contains a newline?
- Valid SQL query return empty
- mysql query – how to escape apostrophe?
- Query the WordPress database to get data together with replaced information
- Optimize slow SQL query for multiple meta values
- Updating with $qpdb->query() always returns 0 rows affected
- How Do I Delete WordPress Posts Older Than 400 Days, From A WordPress Category
- How to return count of custom post type posts with a specific custom field value via $wpdb?
- WordPress Mysql query and Duplicate
- Help with Related Posts Function
- How to delete all images from code in all post_content
- I want to get on those users their meta value are like “AGENT” .. but this query is not working
- Display data from phpMyAdmin with WordPress
- Displaying data from custom table
- Get 2 meta values from meta key column
- PHP Fatal error: Uncaught Error: Call to a member function insert() on null
- SQL query to delete users with multiple meta keys and comments
- SQL query to bulk change short code in all posts
- OR condition not working
- Trouble migrating custom post types from non-wordpress cms
- Are there any best practices for creating a Like/Favourite feature in WordPress using custom MySQL tables and without any plugins?
- Performance of wp_get_attachment_image_srcset() and wp_get_attachment_image_url()
- How to make MySQL search queries with quotes
- Custom MySQL Query for Post and Post Meta
- Mysql query and odd results
- sql for querying post and their category
- Access Tables with number prefix
- Custom API how to return int field
- Problem in MySql query on WordPress [closed]
- How to log in to phpMyAdmin with WAMP, what is the username and password?
- Setting up foreign keys in phpMyAdmin?
- phpMyAdmin: secret passphrase?
- Forbidden :You don’t have permission to access /phpmyadmin on this server
- ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)
- Fix Access denied for user ‘root’@’localhost’ for phpMyAdmin
- #1045 – Access denied for user ‘root’@’localhost’ (using password: YES)
- MySQL Error #1133 – Can’t find any matching row in the user table
- phpmyadmin #1045 Cannot log in to the MySQL server. after installing mysql command line client
- How to create a foreign key in phpmyadmin
- importing a CSV into phpmyadmin
- MySQL: Can’t create table (errno: 150)
- MySQL: How to reset or change the MySQL root password?
- MySQL Daemon Failed to Start – centos 6
- MySQL said: Documentation #1045 – Access denied for user ‘root’@’localhost’ (using password: NO)
- Moving WordPress from MAMP to WAMP, can’t access pages
- Moving WordPress from MAMP to WAMP, can’t access pages
- How to display SQL query that ran in query?
- How can I create a meta_query with an array as meta_field?
- What SQL Query to do a simple find and replace
- Query multiple meta key values?
- How to Optimize WP site for millions of posts
- the_date() not working
- Return only Count from a wp_query request?
- How to get comments by post ID?
- Is there a way to list all used/unused WP templates?
- Get Featured Image via direct sql query
- Differences between wpdb->get_results() and wpdb->query()
- Is there a way of increasing the speed of this query?
- Get all image from single page using this query
- How can I query all users who registered today?
- Get Terms by IDs with IDs order
- Reversing the order of posts AFTER the query is performed
- what are the numbers between curly brackets in search query
- Using WordPress public query variables
- How to Use Wildcards in $wpdb Queries Using $wpdb->get_results & $wpdb->prepare?
- When/why does ‘$query->get( ‘tax_query’ );’ return empty?
- How to get link and title of next and previous post on single page
- Create pagination and order according to alphabet
- wpdb get posts by taxonomy SQL
- How to List Events by Year and Month Using Advanced Custom Fields?
- Is there any difference between hooks posts_where with posts_join and posts_search performance wise?
- wordpress query – orderby child post date
- Optimize Multiple Taxonomy Term MySQL Query?
- How to display Section for certain time