4

これは少し奇妙です。「update_post_meta」を使用して、Wordpress のカスタム フィールドを更新しています。update_post_meta($post_id, 'Test_Field', 'Test Value'); を実行すると カスタムフィールドは問題なく更新されますが、文字列値を使用すると更新されません:

$test_value = "Test";
 echo $test_value; // No problem here
 echo $post_id; // No problem here
 update_post_meta($post_id, 'Test_Field', $test_value);

ご協力ありがとうございました

ストゥ

4

3 に答える 3

4

変数を型でキャストしてみてください。これを試して:

update_post_meta( (int) $post_id, 'Test_Field', (string) $test_value );
于 2012-09-05T17:48:54.647 に答える
1

最初の例では、$post_id とソリューションの $page_id を使用しました。それはタイプミスでしたか?

于 2011-07-12T23:21:45.503 に答える