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:
- 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
- MySQL Error #1133 – Can’t find any matching row in the user table
- MySQL: Can’t create table (errno: 150)
- How can I create a meta_query with an array as meta_field?
- Query multiple meta key values?
- the_date() not working
- Is there a way to list all used/unused WP templates?
- Reversing the order of posts AFTER the query is performed
- what are the numbers between curly brackets in search query
- When/why does ‘$query->get( ‘tax_query’ );’ return empty?
- Remove [gallery] shortcode altogether
- SQL query equivalent to WP User Query
- add_query_arg() XSS Vulnerability
- Custom Query to search through categories
- meta_query on a date range using an array of values
- Can’t find my wordpress DB in phpmyadmin
- Search query -> Show all pages except certain template
- Plugin: register_deactivation_hook works perfectly well, while register_activation_hook suddenly stopped working
- I can’t figure out what’s wrong with this statement. $wpdb->query update
- query statement containing variable won’t execute
- Getting Error Trying to Create Table
- Related post based on content
- WP_User_Query with more than two custom meta values
- how do i register global query in template
- WordPress Custom Query: Combining Two Functions
- Sort query_terms_list for post_tags alphabetically
- Target a page with query
- List only parent attributes on woocommerce admin atrributes page
- Add rewrite rule for archive search
- Query to fetch custom taxonomy along with post title
- My custom pagination not displaying
- Query reversed when I use “category__not_in”
- How to reduce the load / no of queries on MySql Database
- Display result from custom post meta query
- Show certain number of post from tags
- Wpdb empty result only if language is Russian
- Display Upload Author & Get Uploaded Post ID
- Display list of most recent grandchild (third tier) pages
- How can I display a number to represent the order of post?
- Sort order in get_posts [closed]
- Query unique author ids with published post of type job
- Wpdb generates too many queries
- Query posts alphabetically within this function
- Conditional Tag Custom Querys?
- WP Query outputs three items within a div
- How do I troubleshoot Maximum execution time of 60 seconds exceeded in updating a Media File?
- update $wpdb one query
- Admin Post List table Query filtering “WHERE” for custom post type
- How to use a dynamic term id for the query block