添加wp_head()时本地Wordpress站点收到错误;和wp_footer();

时间:2014-01-15 16:24:50

标签: php wordpress localhost

我正在使用本地Wordpress网站,当我添加wp_head()时;和wp_footer();函数进入我的index.php文件,该站点收到“无法加载网页,因为服务器没有发送数据”消息。我在我的htdocs中拥有所有必需的Wordpress文件,而且我正在使用MAMP。当我删除wp_head();和wp_footer();该网站显示备份的功能。造成这种情况的原因是什么?

<!DOCTYPE html>
<html>
  <head>
    <title><?php bloginfo('name'); ?></title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <?php wp_head();?>
  </head>
  <body>
    <a class="btn" href="#">hello</a>

    <?php wp_footer()
  </body>
</html>

/**
 * Load CSS and Javascript
 */

function load_styles_and_scripts(){

    //load styles
    wp_enqueue_style(
            'bootstrap-styles',
            get_template_directory_uri() . '/css/bootstrap.min.css'
        );
    wp_enqueue_style(
            'main-styles',
            get_template_directory_uri() . '/style.css'
        );

    //load scripts
    wp_enqueue_scripts(
            'jquery',
            'http://code.jquery.com/jquery.min.js'
        );

    wp_enqueue_scripts(
            'bootstrap-scripts',
            get_template_directory_uri() . '/js/bootstrap.min.js'
        );


}

add_action('wp_enqueue_scripts', 'load_styles_and_scripts');

1 个答案:

答案 0 :(得分:0)

load_styles_and_scripts()函数中,加载函数应为wp_enqueue_script