我定義了一個名爲「firstname」的工作函數,它可以正常執行。在我的第二個功能中,我想引用它。我究竟做錯了什麼?我知道我使用的PHP調用不起作用,但希望您瞭解我的目標是什麼。這當然是在我的functions.php文件中。在wordpress函數中調用之前定義的函數
// Define function to get form field values:
// Working:
function firstname(){
$firstname = $_GET["Field1"];
echo $firstname;
}
// Find and replace values:
function replace_text_wps($text) {
$text = str_replace('firstname', '<?php firstname(); ?>', $text);
$text = str_replace('tech support', '<a href="/techsupport">Tech support</a>', $text);
$text = str_replace('computers', '<a href="/computers">Computers</a>', $text);
return $text;
}
add_filter('the_content', 'replace_text_wps');
我不認爲你想回聲'$ firstname'回來。我想你想'返回$ firstname;'。 – mrtsherman
謝謝!這解決了我的渲染問題。 – gabearnold