私は予期しない結果を得ている簡単なWordPressショートコードを持っています。これは動作しないものです:私はこの変数が参照していると思いますか?
$this_post_id = do_shortcode('[cred_post_parent get="id"]');
$testString = $this_post_id;
$parent_id = wpcf_pr_post_get_belongs($testString, 'wa-listing');
$variableType1 = gettype($testString);
$variableType2 = gettype($this_post_id);
$variableType3 = gettype($parent_id);
return $variableType1.': '.$testString.' | '.$variableType2.': '.$this_post_id.' | '.$variableType3.': '.$parent_id;
これが返されます:文字列:468 |文字列:468 |ブール:
場合、私のようなので、2行目に$たTestStringの値でハードコード:
$testString = '468';
結果は次のとおりです。文字列:468 |文字列:468 |文字列:56
最後の変数は、私が必要とするものを返すようになりました。
私の疑惑は、変数$ this_post_idがショートコードのオブジェクトを参照しているという疑いがありますが、私はこれを回避しようとすることに成功していません。
内容、型、(後者を使用して)変数の参照を見るには 'var_dump($ variable)'または 'debug_zval_dump($ variable)'を使います。 – Sven