2

移行された WordPress に取り組んでおり、サイトの URL が変更されました。プラグインによって保存されたシリアル化されたデータを除いて、すべて正常に動作します。

データはwp_options テーブルoption_value 列に、プラグインが保存した各レコードに保存されます。したがって、データはまだ残っています。問題は、URL が変更されたときに再シリアル化されなかったことです (文字列コンテンツの数は、まだ古い URL の長さと見なされています)。そのため、プラグインが正しく機能していません。

したがって、更新が必要なレコードを正確に見つけるには、

$t1 = $wpdb->prefix . "vslider";
$t2 = $wpdb->prefix . "options"; 

$records_ineed = $wpdb->get_results("SELECT * FROM '".$t1."', '".$t2."' WHERE '".$t1."'.option_name='".$t2."'.option_name");

これにより、再シリアル化する必要があるレコードが正確に得られます (プラグイン テーブルで作成されたレコードの名前と、wp_option テーブルで作成されたレコードと一致します)。

私は今何をしますか?それぞれの option_value のみを取得し、シリアル化を解除し、再シリアル化して、データベース内の既存の値を更新するにはどうすればよいですか? 再シリアル化された値を新しいテーブルに保存し、そのテーブルから wp_options に戻す必要がありますか? どのように?そうでなければ、他の解決策は何ですか?

4

1 に答える 1

1

その必要はありません。必要なのは、値をそのままインポートすることです。これは配列であり、データを変更しない限り、そのままで問題なく動作します。

いずれにしても、wp サイトを別の URL に移行するときに、wp-options テーブルの列を 1 つずつ読み取る必要はまったくありません。

必要なことは、Original( old-domain) サイトから SQL をダンプし、にインポートしてnew-domain、これらのクエリを実行することだけです。

/**
To update WordPress options with the new blog location, use the following SQL command:
**/

UPDATE wp_options SET option_value = replace(option_value, 'http://www.old-domain.com', 'http://www.new-domain.com') WHERE option_name = 'home' OR option_name = 'siteurl';

/**
After that you will need to fix URLs of the WordPress posts and pages, which translated from post slug, and stored in database wp_posts table as guid field. The URL values in this field are stored as abolute URLs instead of relative URLs, so it needs to be changed with the following SQL query:
**/

UPDATE wp_posts SET guid = replace(guid, 'http://www.old-domain.com','http://www.new-domain.com');

/**
If you have linked internally within blog posts or pages with absolute URLs, these links will point to wrong locations after you move the blog location. Use the following SQL commands to fix all internal links to own blog in all WordPress posts and pages:
**/

UPDATE wp_posts SET post_content = replace(post_content, 'http://www.old-domain.com', 'http://www.new-domain.com');

確認のために、これらのコマンドを実行した後、オプション テーブルに戻り、データに関して home 関数と site_url 関数の両方が正しいことを確認しますnew-domain

なんらかの理由でまだ必要な場合は、データをオプション テーブルに手動で直接挿入する必要があります ( ?? なぜ )get_post_meta()update_post_meta()

于 2013-04-13T02:05:35.923 に答える