| 657 | | $posts = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts"); |
| 658 | | |
| 659 | | if ( ! empty($posts) ) foreach ($posts as $post) { |
| 660 | | $status = $post->post_status; |
| 661 | | $type = 'post'; |
| 662 | | |
| 663 | | if ( 'static' == $status ) { |
| 664 | | $status = 'publish'; |
| 665 | | $type = 'page'; |
| 666 | | } else if ( 'attachment' == $status ) { |
| 667 | | $status = 'inherit'; |
| 668 | | $type = 'attachment'; |
| 669 | | } |
| 670 | | |
| 671 | | $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_status = %s, post_type = %s WHERE ID = %d", $status, $type, $post->ID) ); |
| 672 | | } |
| | 657 | $wpdb->query(" |
| | 658 | UPDATE $wpdb->posts |
| | 659 | SET post_type = CASE |
| | 660 | WHEN post_status = 'page' |
| | 661 | THEN 'page' |
| | 662 | WHEN post_status = 'attachment' |
| | 663 | THEN 'attachment' |
| | 664 | ELSE 'post' |
| | 665 | END, |
| | 666 | post_status = CASE |
| | 667 | WHEN post_status = 'page' |
| | 668 | THEN 'publish' |
| | 669 | WHEN post_status = 'attachment' |
| | 670 | THEN 'inherit' |
| | 671 | ELSE post_status |
| | 672 | END; |
| | 673 | "); |