簡體   English   中英

Wordpress 無法加載樣式:加載資源失敗:服務器響應狀態為 404(未找到)

[英]Wordpress can't load styles: Failed to load resource: the server responded with a status of 404 (Not Found)

我正在嘗試將 HTML 靜態網站轉換為 WordPress。 我一開始就被卡住了,我需要從我的function.php 中的css 文件夾加載我的所有樣式

<?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' );
}

?>

這是我位於以下目錄中的所有文件:

在此處輸入圖片說明

然后我試圖檢查谷歌瀏覽器中的元素我得到了一堆錯誤,它們都在說同樣的事情:加載資源失敗:服務器響應狀態為 404(未找到)

在我的header.php 中,我正在調用<?php wp_head(); ?> <?php wp_head(); ?>就在</head>標簽之前。 在我的index.php文件中,我調用<?php get_header(); ?> <?php get_header(); ?>

我試圖移動add_action( 'wp_enqueue_scripts', 'load_styles' ); 至底部;

我試圖將 Filezilla 中文件夾的權限設置為 777;

我嘗試使用get_stylesheet_uri()而不是get_template_directory_uri()

而且我不知道我接下來應該做什么。

你可能已經想通了,但看起來你在 style.css 之前錯過了/css/

它應該是這樣的:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM