私はドロップダウンの選択に基づいて私のPHPファイルの1つを含めることができるように設定しようとしています。私はそれを行うように見える他の答えを見つけましたが、私はそれを試すとき、私はエラー "未定義の関数"を取得します。私は私が「get_template_part」のエラーを取得するオプションのいずれかを選択してボタンを押すとドロップダウンの選択に基づいてPHPファイルを含める
<?php
$includes=array(
'phpfile1'=>'phpfile1.php',
'phpfile2'=>'phpfile2.php'
);
if(isset($_POST['cmtype']) && array_key_exists($_POST['cmtype'], $includes)) :
get_template_part($includes[$_POST['cmtype']]);
endif;
?>
<form id="selection_form" action="" method="post">
<select name="cmtype" id="cmtype">
<option value="default"> </option>
<option value="phpfile1">PHP file 1</option>
<option value="phpfile2">PHP File 2</option>
</select>
<input type="submit" name="select_mode_submit" value="Get File">
</form>
:
オリジナルの答えはここにここにOriginal
であることは私のコードです。 IF文にある関数と何か関係があると思いますが、それを修正する方法がわかりません。
get_template_part()はどこで定義されていますか? – markdwhite
完全なエラーが役に立ちます –
この関数 'get_template_part'を持つファイルがありますか? –