简体   繁体   English

如何在WordPress page.php中加载style.css根目录,目录中包含single.php

[英]How to load style.css root directory in WordPress page.php, single.php in contents

I am making a WordPress theme. 我正在制作WordPress主题。 But I have a problem. 但是我有一个问题。 style.css stylesheet is not loading in page.php contents. style.css样式表未加载在page.php内容中。 When I edit a post in wp editor and add <div class=w3-red"> <button class="w3-btn w3-red"> and more related codes. When I published a post, they are not showing on front-end. I think WordPress doesn't support the page style customization option with wp editor. I have also added my own style.css in header.php. 当我在wp编辑器中编辑帖子并添加<div class=w3-red"> <button class="w3-btn w3-red">和更多相关代码时,当我发布帖子时,它们并没有显示在前面-最后,我认为WordPress不支持wp编辑器中的页面样式自定义选项,我还在header.php中添加了自己的style.css。

I am using w3.css stylesheet in my web root directory. 我在Web根目录中使用w3.css样式表。 style.css style.css

<div class="w3-card w3-red"> Hello </div>

This code in not loading in frontend. 此代码未在前端加载。

Please refer this link 请参考此链接

or 要么

Just put your stylesheets (style.css) in a directory wp-content\\themes\\[YOUR_THEME]\\css\\ . 只需将样式表(style.css)放在目录wp-content\\themes\\[YOUR_THEME]\\css\\ Then you can link stylesheet through simply put below code (theme header.php file). 然后,您可以通过简单地将下面的代码(主题header.php文件)链接样式表。

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

Your style.css when you creating a theme it must be in on the same folder as your index.php 创建主题时,您的style.css必须与index.php位于同一文件夹中

in your head load the style using: 在您的头部中使用以下样式加载样式:

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

if your stylesheet is on css folder load it using this : 如果您的样式表位于css文件夹中,请使用以下命令加载它:

<link rel="stylesheet" type="text/css" href="<?php echo get_template_directory_uri();?>/folder/name.css">

Another way is accessing image using css file location as the reference point, eg 另一种方法是使用css文件位置作为参考点访问图像,例如

.class-name{ 。班级名称{

background-image:url("../images/file-name"); background-image:url(“ ../ images / file-name”); //one level up, then images folder //上一层,然后是图像文件夹

background-image:url("../../images-directory-02/images/file-name"); background-image:url(“ ../../ images-directory-02 / images / file-name”); //two levels up, then two folders in //向上两个级别,然后进入两个文件夹

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM