Created
March 30, 2016 11:06
-
-
Save k1sul1/2bbbbd6908f36c653e83482dce8a5e1e to your computer and use it in GitHub Desktop.
wp-fix-post-permalinks.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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