style.css在wordpress中不起作用
我对Wordpress有一个问题,我已经创建了所有需要的文件,包括style.css index.php等等,但是页面没有设置样式。在页眉中,除其他外,我把这个style.css在wordpress中不起作用,css,wordpress,header,styles,stylesheet,Css,Wordpress,Header,Styles,Stylesheet,我对Wordpress有一个问题,我已经创建了所有需要的文件,包括style.css index.php等等,但是页面没有设置样式。在页眉中,除其他外,我把这个 <link rel="stylesheet" type="text/css" href="<?php bloginfo('template_url'); ?>/css/bootstrap.css" /> <link rel="stylesheet" type="text/css" href="<?ph
<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_url'); ?>/css/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_url'); ?>/css/bootstrap-responsive.css" />
<link rel="stylesheet" type="text/css" href="text/css" href="<?php bloginfo('template_url'); ?>/css/style.css" />
添加除style.css
以外的样式表,打开function.php
并添加以下代码
add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );
function theme_name_scripts() {
wp_enqueue_style( 'style-name', get_stylesheet_uri() . "/css/bootstrap.css" );
wp_enqueue_style( 'style-name', get_stylesheet_uri() . "/css/bootstrap-responsive.css" );
}
add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );
function theme_name_scripts() {
wp_enqueue_style( 'style-name1', get_stylesheet_uri() . "/css/style.css" );
wp_enqueue_style( 'style-name2', get_stylesheet_uri() . "/css/bootstrap.css" );
}
使用thins添加style.css文件:
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>">
添加除style.css
以外的样式表,打开function.php
并添加以下代码
add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );
function theme_name_scripts() {
wp_enqueue_style( 'style-name', get_stylesheet_uri() . "/css/bootstrap.css" );
wp_enqueue_style( 'style-name', get_stylesheet_uri() . "/css/bootstrap-responsive.css" );
}
add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );
function theme_name_scripts() {
wp_enqueue_style( 'style-name1', get_stylesheet_uri() . "/css/style.css" );
wp_enqueue_style( 'style-name2', get_stylesheet_uri() . "/css/bootstrap.css" );
}
使用thins添加style.css文件:
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>">
我也有同样的问题,但我通过仔细查看代码来修复它。这是我以前写的:
<link href="<?php bloginfo('stylesheet_url'); ?> rel="stylesheet" type="text/css" media="all" />
我也有同样的问题,但我通过仔细查看代码来修复它。这是我以前写的:
<link href="<?php bloginfo('stylesheet_url'); ?> rel="stylesheet" type="text/css" media="all" />
将以下内容添加到functions.php中,它应该可以工作
function EnqueueMyStyles() {
wp_enqueue_style('my-custom-style', get_template_directory_uri() . '/css/my-custom-style.css', false, '20150320');
wp_enqueue_style('my-google-fonts', '//fonts.googleapis.com/css?family=PT+Serif+Caption:400,400italic', false, '20150320');
wp_enqueue_style('my-main-style', get_stylesheet_uri(), false, '20150320');
}
}
add_action('wp_enqueue_scripts', 'EnqueueMyStyles');
将以下内容添加到functions.php中,它应该可以工作
function EnqueueMyStyles() {
wp_enqueue_style('my-custom-style', get_template_directory_uri() . '/css/my-custom-style.css', false, '20150320');
wp_enqueue_style('my-google-fonts', '//fonts.googleapis.com/css?family=PT+Serif+Caption:400,400italic', false, '20150320');
wp_enqueue_style('my-main-style', get_stylesheet_uri(), false, '20150320');
}
}
add_action('wp_enqueue_scripts', 'EnqueueMyStyles');
当你在chrome或其他浏览器上查看时,你的插件或CSS中也有2个站点URL或主页URL。并在新选项卡中打开此项(顺便说一句,此项不应可访问)::
然后试着把
当您在chrome或某些浏览器上查看时,插件或CSS中也有2个站点URL或主URL时,在本地主机或任何>phpmyadmin>数据库(WordPress)>wp\u选项>>“siteurl”和选项值中的“home”中不带“/”和“/p>”。并在新选项卡中打开此项(顺便说一句,此项不应可访问)::
然后试着把
“/”不带本地主机中的“”,或任何>phpmyadmin>数据库(WordPress)>wp\u选项>>“siteurl”和选项值中的“home”替换为bloginfo
中的模板目录中的模板,所有操作如下:
<link ... href="<?php bloginfo('template_directory'); ?>/css/bootstrap.css" />
<link ... href="<?php bloginfo('template_directory'); ?>/style.css" />
用bloginfo
中的template\u目录
替换template\u url
,所有操作如下:
<link ... href="<?php bloginfo('template_directory'); ?>/css/bootstrap.css" />
<link ... href="<?php bloginfo('template_directory'); ?>/style.css" />
打开function.php文件并通过以下代码
add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );
function theme_name_scripts() {
wp_enqueue_style( 'style-name', get_stylesheet_uri() . "/css/bootstrap.css" );
wp_enqueue_style( 'style-name', get_stylesheet_uri() . "/css/bootstrap-responsive.css" );
}
add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );
function theme_name_scripts() {
wp_enqueue_style( 'style-name1', get_stylesheet_uri() . "/css/style.css" );
wp_enqueue_style( 'style-name2', get_stylesheet_uri() . "/css/bootstrap.css" );
}
打开function.php文件并完成以下代码
add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );
function theme_name_scripts() {
wp_enqueue_style( 'style-name', get_stylesheet_uri() . "/css/bootstrap.css" );
wp_enqueue_style( 'style-name', get_stylesheet_uri() . "/css/bootstrap-responsive.css" );
}
add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );
function theme_name_scripts() {
wp_enqueue_style( 'style-name1', get_stylesheet_uri() . "/css/style.css" );
wp_enqueue_style( 'style-name2', get_stylesheet_uri() . "/css/bootstrap.css" );
}
在functions.php中添加此代码,它将style.css文件链接到WordPress主题
function load_scripts() {
wp_enqueue_style( 'stylecss', get_stylesheet_uri() );
}
add_action('wp_enqueue_scripts', 'load_scripts' );
在functions.php中添加此代码,它将style.css文件链接到WordPress主题
function load_scripts() {
wp_enqueue_style( 'stylecss', get_stylesheet_uri() );
}
add_action('wp_enqueue_scripts', 'load_scripts' );
你的目录是什么样子的?解析后的HTML看起来如何?您是否注意到该链接(最后一行)中有两个href属性?您的目录是什么样子的?解析后的HTML看起来如何?您是否注意到该链接(最后一行)中有两个href属性?我的意思是您可以随时尝试这个。如果不起作用,很容易返回。我没有读到你的问题。但这就是我一直在寻找的解决办法,我自己也找到了解决办法。只要记住一开始是什么,我的意思是你可以试试这个。如果不起作用,很容易返回。我没有读到你的问题。但这就是我一直在寻找的解决办法,我自己也找到了解决办法。请记住首先是什么。wp_enqueue_样式中的style-name必须是唯一的。使用add_操作('wp_排队_脚本','theme_name_脚本');函数主题名称脚本({wp_-name_-scripts(){wp_-enqueue_-style('style-name1',get_-stylesheet_-uri()。“/css/bootstrap.css”);wp_-enqueue_-style('style-name2',get_-stylesheet_-uri()。/css/bootstrap-responsible.css”)}wp_-enqueue_-style内的样式名称必须是唯一的。使用add_操作('wp_排队_脚本','theme_name_脚本');函数主题名称脚本({wp_-name_-scripts(){wp_-enqueue_-style('style-name1',get_-stylesheet_-uri()。“/css/bootstrap.css”);wp_-enqueue_-style('style-name2',get_-stylesheet_-uri()。“/css/bootstrap-responsible.css”)}您的答案没有正确确定范围。