Skip to content

Instantly share code, notes, and snippets.

@k1sul1
Created March 30, 2016 11:06
Show Gist options
  • Save k1sul1/2bbbbd6908f36c653e83482dce8a5e1e to your computer and use it in GitHub Desktop.
Save k1sul1/2bbbbd6908f36c653e83482dce8a5e1e to your computer and use it in GitHub Desktop.
wp-fix-post-permalinks.php
<?php
global $wpdb;
$threads = $wpdb->get_results("SELECT ID, post_title, post_name FROM wp_posts WHERE post_type = 'topic'");
foreach($threads as $thread){
$sanitized_title = sanitize_title($thread->post_title);
$id = $thread->ID;
$wpdb->query("UPDATE wp_posts SET post_name = '$sanitized_title' WHERE ID = $id");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment