2015-09-03 28 views
0

我想添加新的樣式表到wordpress,我通過函數添加哪裏都是舊的.css文件,他們正在工作。所以當我添加新文件時,wordpress沒有看到它,當我點擊來自視圖源的文件鏈接時,我得到404錯誤,但該文件位於相同的文件夾中,並具有與所有舊的.css文件完全相同的鏈接名稱。 我試圖清理緩存,更新固定鏈接,但問題仍然相同。WordPress的沒有看到我的新style.css文件

<link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/custom/assets/css/customname.css"/> 
<link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/custom/assets/css/news-internal.css"/> 
<link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/custom/assets/css/skinprofile.css"/> 

所以新聞internal.cssskinprofile.css工作和customname.css鏈接404錯誤.. 什麼我失蹤?我可以嘗試改變什麼?

+0

您使用的是兒童主題嗎? – vitozev

+0

我使用的是thesis_185主題,但有很多自定義更改。主題如何影響新文件,但如果我以相同方式導入它們,則不是舊文件。 –

回答

0

問題出在我的filezilla客戶端,我的文件上傳失敗,但我可以看到它。 我再次上傳它,之後我可以通過鏈接到達我的.css文件。

0

您無法通過「bloginfo()」添加樣式。嘗試

function name_scripts() { 
    wp_enqueue_style('bs', get_template_directory_uri() . '/bs/css/bootstrap.min.css'); 
    wp_enqueue_style('style', get_template_directory_uri() . '/style.css'); 
    wp_enqueue_script('bsscript', get_template_directory_uri() . '/bs/js/bootstrap.min.js', array(), '1.0.0', true); 
    wp_enqueue_script('antoher-script', get_template_directory_uri() . '/bs/js/eschadl.js', array(), '1.0.0', true); 
} 
add_action('wp_enqueue_scripts', 'name_scripts'); 

所以

function name_scripts() { ... } => Name of your Function, e.g. mytemplate_scripts() 

wp_enqueue_style(); => for CSS-Files 

wp_enqueue_scriptJS(); => for CSS-Files 
您的括號ü之間

所以必須注意:

'bs' => Name of your Style-Sheet you want. It can be different to the real name of the file 
get_template_directory_uri() => same like bloginfo() 
afterward(!) ". '/style.css' => . is connector between url and your file 

所以URL看起來像

http://www.yourwebsite.de/style.css 

而在你的WordPress

http://www.yourwebsite.de/wp-content/themes/themesname/style.css 

如果您的文件在另一個方向上必須修改點後的路徑(「。」)。 「)

wp_enqueue_style('test', get_template_directory_uri() . '/order1/order2/file.min.css'); 

因此,在你的WordPress看起來

http://www.yourwebsite.de/wp-content/themes/themesname/order1/order2/file.min.css 
0

首先去查看源代碼,並檢查你的CSS文件‘customname.css’上市與否。如果在視圖中顯示文件然後點擊該文件的鏈接仍然會得到404,然後首先在文件夾中檢查文件名「customname.css」,然後通過比較視圖源路徑和目錄結構來檢查整個路徑。同樣的問題,然後檢查你是使用兒童主題還是簡單主題?

<link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/custom/assets/css/customname.css"/> 
<link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/custom/assets/css/news-internal.css"/> 
<link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/custom/assets/css/skinprofile.css"/> 
相關問題