有很多事情会导致您在上面(在 cmets 中)描述的错误。
其中一个是分别在页眉和页脚中缺少的wp_footer()、wp_header() 函数,但如果您没有手动删除它们,它们将包含在基础中。
另一个原因是js/jQuery加载错误。您的主题可能就是这种情况,因为确实似乎 wpcf7 脚本没有加载..
wp-foundation 主题实际上是在使用一个非常糟糕的做法,即注销 wp 自己的 jQuery 并加载“个人”版本。
我什至无法开始列举原因why it is wrong。
虽然不是 100% 肯定,但这可能是原因之一(如果不是原因)
代码在functions.php中
/************* ENQUEUE JS *************************/
/* pull jquery from google's CDN. If it's not available, grab the local copy. Code from wp.tutsplus.com :-) */
$url = 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'; // the URL to check against
$test_url = @fopen($url,'r'); // test parameters
if( $test_url !== false ) { // test if the URL exists
function load_external_jQuery() { // load external file
wp_deregister_script( 'jquery' ); // deregisters the default WordPress jQuery
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'); // register the external file
wp_enqueue_script('jquery'); // enqueue the external file
}
add_action('wp_enqueue_scripts', 'load_external_jQuery'); // initiate the function
} else {
function load_local_jQuery() {
wp_deregister_script('jquery'); // initiate the function
wp_register_script('jquery', bloginfo('template_url').'/javascripts/jquery.min.js', __FILE__, false, '1.7.2', true); // register the local file
wp_enqueue_script('jquery'); // enqueue the local file
}
add_action('wp_enqueue_scripts', 'load_local_jQuery'); // initiate the function
}
正确的代码应该是
function load_local_jQuery() {
wp_enqueue_script('jquery'); // enqueue the local file
}
add_action('wp_enqueue_scripts', 'load_local_jQuery'); // initiate the function
加载 wp 自己的 jQuery ...
另见here和here
另外,在测试时禁用所有其他插件,并确保您使用最新版本的 wpcf7 和 wp 本身...