WP2.5で同じタイトル名をつけると投稿できない
4 月 16th, 2008 by
admin
というわけでWordpres2.5は結構バグがあるんですが、今回もちょっと困ったことに。
まったく同じタイトルを付けると投稿が出来なくなるというもの。
自分で使ってる分にはそうそう重複タイトルってないんですが、PS3 Photo Galleryではしょっちゅうありますので困っていました。
この件について調べてみると、やはりWPフォーラムにも話題が上っており、解決作も提示されていましたので適用してみました。
wp-includes/post.phpの1269~1279行目あたりに、urlencode、urldecodeを追加・変更することで解消
if ($post_name_check || in_array($post_name, $wp_rewrite->feeds) ) {
$suffix = 2;
do {
$alt_post_name = substr($post_name, 0, 200-(strlen($suffix)+1)). "-$suffix";
$alt_post_name = urldecode ($alt_post_name); //★追加
// expected_slashed ($alt_post_name, $post_name, $post_type)
$post_name_check = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_name = ‘$alt_post_name’ AND post_type = ‘$post_type’ AND ID != %d AND post_parent = %d LIMIT 1", $post_ID, $post_parent));
$suffix++;
} while ($post_name_check);
$post_name =urlencode($alt_post_name); //★変更
}
$suffix = 2;
do {
$alt_post_name = substr($post_name, 0, 200-(strlen($suffix)+1)). "-$suffix";
$alt_post_name = urldecode ($alt_post_name); //★追加
// expected_slashed ($alt_post_name, $post_name, $post_type)
$post_name_check = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_name = ‘$alt_post_name’ AND post_type = ‘$post_type’ AND ID != %d AND post_parent = %d LIMIT 1", $post_ID, $post_parent));
$suffix++;
} while ($post_name_check);
$post_name =urlencode($alt_post_name); //★変更
}
これで無事に同じタイトル名でも投稿できるようになりました。
タグ: wordpress, バグ