CSS没有链接到HTML页面模板 [英] CSS not linking to HTML Page Template
问题描述
我在 localhost wordpress
中试过,它在那里正常工作。网站,并尝试将CSS文件链接到HTML文件我没有得到CSS效果。
我使用以下地址位置将CSS链接到我的HTML文件:
< link href =/ wordpress / wp-content / themes / ThemeName / file1.css =stylesheet/ >
如何将CSS文件链接到我的HTML?
PS:我将我的HTML文件链接到我的PHP文件以创建页面模板为
require TEMPLATEPATH。'/ file1.html')
也没有文件夹名称为 wordpress
在控制面板目录中。
我的HTML和CSS文件的地址位置是 /home3/username/public_html/wp-content/themes/ThemeName/file1.html
您不应在模板中编写完整路径。 Wordpress为此提供了函数,如 get_stylesheet_directory_uri
,它返回当前主题文件夹的uri。所以要链接你的CSS你应该这样做:
< link href =<?php echo get_stylesheet_directory_uri();? > /file1.cssmedia =allrel =stylesheettype =text / css/>
但是您应该考虑将您的css从 这样Wordpress会添加 I tried in the But when I try for my live website and try to link the CSS files to the HTML file I do not get the CSS effects. I link the CSS to my HTML file using the following address location : How can I possibly link the CSS files to my HTML? PS : I am linking my HTML file to my PHP file to create the Page Template as Also there is no folder named You shouldn't write full path like that in your template. Wordpress provide functions for that, like But you should consider linking your css from That way Wordpress will add the 这篇关于CSS没有链接到HTML页面模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! functions.php $ c
$ p $ function my_scripts()
{
wp_enqueue_style('my_style ',get_stylesheet_directory_uri()。'/file1.css');
}
add_action('wp_enqueue_scripts','my_scripts');
< link> $ c $当调用
wp_head()
时,头部中的样式表的c>标签。localhost wordpress
and it works fine there.<link href="/wordpress/wp-content/themes/ThemeName/file1.css" rel="stylesheet" />
require(TEMPLATEPATH.'/file1.html')
wordpress
in the control panel directory.
The address location for my HTML and CSS file is /home3/username/public_html/wp-content/themes/ThemeName/file1.html
get_stylesheet_directory_uri
that returns the uri of your current theme folder. So to link your css you should do this:<link href="<?php echo get_stylesheet_directory_uri(); ?>/file1.css" media="all" rel="stylesheet" type="text/css" />
functions.php
as it's a better practice:function my_scripts()
{
wp_enqueue_style( 'my_style', get_stylesheet_directory_uri() . '/file1.css' );
}
add_action( 'wp_enqueue_scripts', 'my_scripts' );
<link>
tag for your stylesheet in the head when wp_head()
is called.