duanbigan7765 2015-04-28 14:03
浏览 802

Wordpress无法加载样式:无法加载资源:服务器响应状态为404(未找到)

I'm trying to convert HTML static website to WordPress. I'm stuck at the very beginning, where I need to load all my styles from css folder in my function.php

<?php 
// Loading styles

add_action( 'wp_enqueue_scripts', 'load_styles' );
function load_styles() {

    wp_enqueue_style( 'animate', get_template_directory_uri() . '/css/animate.css' );
    wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/css/font-awesome.css' );
    wp_enqueue_style( 'font-awesome2', get_template_directory_uri() . '/css/font-awesome2.css' );
    wp_enqueue_style( 'framework', get_template_directory_uri() . '/css/framework.css' );
    wp_enqueue_style( 'owl', get_template_directory_uri() . '/css/owl.theme.css' );
    wp_enqueue_style( 'style', get_template_directory_uri() . 'style.css' );
}

?>

Here are all my files located in the following directory:

enter image description here

And then I'm trying to inspect element in Google Chrome I got a bunch of errors that are saying the same thing: Failed to load resource: the server responded with a status of 404 (Not Found)

In my header.php I'm calling <?php wp_head(); ?> right before the </head> TAG. In my index.php file I'm calling <?php get_header(); ?>

I tried to move add_action( 'wp_enqueue_scripts', 'load_styles' ); to the bottom;

I tried to set permissions for my folders in Filezilla to 777;

I tried to use get_stylesheet_uri() instead of get_template_directory_uri();

And I don't know what I supposed to do next.

  • 写回答

1条回答 默认 最新

  • douxun4860 2015-11-17 18:45
    关注

    You've probably already figured this out but it looks like you missed /css/ before your style.css

    It should look something like this:

    wp_enqueue_style( 'style', get_template_directory_uri() . '/css/style.css' );

    评论

报告相同问题?

悬赏问题

  • ¥15 如何提取csv文件中需要的列,将其整合为一篇完整文档,并进行jieba分词(语言-python)
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键
  • ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符
  • ¥15 NX MCD仿真与博途通讯不了啥情况
  • ¥15 win11家庭中文版安装docker遇到Hyper-V启用失败解决办法整理
  • ¥15 gradio的web端页面格式不对的问题
  • ¥15 求大家看看Nonce如何配置
  • ¥15 Matlab怎么求解含参的二重积分?