Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 调用几个CSS文件_Php_Html_Css_Wordpress - Fatal编程技术网

Php 调用几个CSS文件

Php 调用几个CSS文件,php,html,css,wordpress,Php,Html,Css,Wordpress,我正在将Html主题转换为WordPress,这个主题包括几个.CSS文件 我尝试了几种方法将它们调用到head.php中,但都没有成功 我尝试的方式: 进入style.css: @import url('/css/skel.css'); @import url('/css/style.css'); @import url('/css/style-desktop.css'); @import url('/css/style-noscript.css'); 并将其放入Header.php: &l

我正在将Html主题转换为WordPress,这个主题包括几个
.CSS
文件

我尝试了几种方法将它们调用到
head.php
中,但都没有成功

我尝试的方式:

进入
style.css

@import url('/css/skel.css');
@import url('/css/style.css');
@import url('/css/style-desktop.css');
@import url('/css/style-noscript.css');
并将其放入
Header.php

<link href="<?php bloginfo('stylesheet_url'); ?>" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="<?php get_stylesheet_directory(); ?>css/skel.css" />
<link rel="stylesheet" href="<?php get_stylesheet_directory(); ?>css/style.css" />
<link rel="stylesheet" href="<?php get_stylesheet_directory(); ?>css/style-desktop.css" />
<link rel="stylesheet" href="<?php get_stylesheet_directory(); ?>css/style-noscript.css" />
没用! 也用于:

stylesheet_url
template_directory
没用! 其他信息:

Header.php
code

    <!DOCTYPE HTML>
<html>
    <head>
        <title><?php bloginfo( 'title' ); ?></title>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <meta name="description" content="" />
        <meta name="keywords" content="" />
        <!--[if lte IE 8]><script src="<?php echo get_template_directory_uri(); ?>/css/ie/html5shiv.js"></script><![endif]-->
        <script src="<?php echo get_template_directory_uri(); ?>/js/jquery.min.js"></script>
        <script src="<?php echo get_template_directory_uri(); ?>/js/skel.min.js"></script>
        <script src="<?php echo get_template_directory_uri(); ?>/js/init.js"></script>
        <noscript>
            <link rel="stylesheet" href="<?php bloginfo( 'stylesheet_url' ); ?>" type="text/css"/>
        </noscript>
        <!--[if lte IE 8]><link rel="stylesheet" href="<?php bloginfo( 'stylesheet_url' ); ?>/css/ie/v8.css" /><![endif]-->
    <?php wp_head(); ?>
    </head>
    <body>

你试过这个吗

<link rel="stylesheet" href="<?php echo get_stylesheet_directory(); ?>css/style.css" />

get\u stylesheet\u目录
返回绝对服务器路径,而不是URI。您需要回显
获取\u样式表\u目录\u uri()
。请注意,这不会返回尾随斜杠。您需要通过将源添加到中来修改源。例如:

<link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/css/skel.css" />
试试这个

<link href="<?php echo home_url('/');?>wp-content/themes/tmeme name/css/css name.css" rel="stylesheet" type="text/css"/>

尝试从导入url中删除第一个斜杠

@import url('css/skel.css');
@import url('css/style.css');
@import url('css/style-desktop.css');
@import url('css/style-noscript.css');

注意:无论您需要在基本主题文件夹中添加style.css,因为wordpress只解析该文件中的主题元

theme1/style.css
theme1/header.php
theme1/css/other.css
在header.php中

<link rel="stylesheet" href="<?php bloginfo( 'stylesheet_url' ); ?>" type="text/css"/>

尝试使用排队方式


在theme中创建您自己的页面,并在functions.php文件中包含页面。

这应该非常简单,在您使用的任何主题文件夹中,将其添加到functions.php文件中

function add_stylesheets(){ ?>
    <link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri().'/css-filepath-inside-theme-folder-here/somefile.css ?>">

只要css文件位于main style.css文件附近,就应该很好

get\u stylesheet\u目录
返回绝对服务器路径,而不是URI。请参阅我的答案,了解如何正确使用
get\u stylesheet\u directory\u uri
。请注意,它包含一个
echo
和一个尾随斜杠。您可以指定主题文件夹的文件结构吗?我很有信心这能解决你的问题。wordpress开发者hereidk如果这是原因,或者您试图访问哪个页面,请尝试添加page.php和single.php。这是wordpress文件work、about、contact pages中必需的,不应存在,如果是页面,则应为page-work.php、page-about.php,page-contact.php覆盖默认页面。phpNo Roi请看这些部分是include index.html,我将其分开,但我调用了它们,正如您在这张图片中看到的:这是登录页面主题,我不想添加博客帖子或页面(我不需要)。现在一切都好了,除了style.ok我尝试了@import url('/css/style desktop.css');而且对我也不起作用,你需要删除第一条斜线。你试过了吗?已经试过了。嘿,看看这个,我想这一定是我的问题,这些文件不是从主题加载的!!将其更改为,我将给您+1;)@giorgio我在wp_enqueue_样式中更改了它,那么我应该在functions.php中使用哪一个呢?第一个还是第二个?我做了但没有成功!这就是我将这些代码放入functions.php的方式,我得到了以下错误:function add_stylesheets(){警告:call_user_func_array()在第505行的C:\xamppnew\apps\wordpress\htdocs\wp includes\plugin.php中,参数1应为有效回调、函数“add_stylesheets”未找到或函数名无效请仔细查看我的示例。您混淆了php开始标记和结束标记的位置。您在调用函数之前已将其关闭。您需要在函数结束后立即将其关闭打开{并启动php性能关闭}我们所做的只是将HTML和php结合在一起
<link rel="stylesheet" href="<?php bloginfo( 'stylesheet_url' ); ?>" type="text/css"/>
/*
Theme Name: Theme1
Theme URI:
Description: Sample Theme
Author: 
Author URI:
License: GNU General Public License v2.0
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Version: 1.0
*/

@import url("css/other.css"); //sample css file
function add_stylesheets(){ ?>
    <link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri().'/css-filepath-inside-theme-folder-here/somefile.css ?>">
//Add the function to the wordpress head
add_action('wp_head','add_stylesheets');