[英]Why is bloginfo('stylesheet_url') not rendering my style.css?
According to the WordPress Codex I should be able to get style.css rendered with and its not working and nothing is rendering in Console. 根据WordPress Codex,我应该能够用style.css渲染并且不起作用,并且在Console中什么也没有渲染。
This is my header.php: 这是我的header.php:
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo('charset'); ?>">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title><?php bloginfo('name'); ?> | <?php is_front_page() ? bloginfo('description') : wp_title(''); ?></title>
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<!-- Place favicon.ico and apple-touch-icon(s) here -->
<link rel="shortcut icon" href="http://cdn.ink.sapo.pt/3.1.10/img/favicon.ico">
<link rel="apple-touch-icon" href="http://cdn.ink.sapo.pt/3.1.10/img/touch-icon-iphone.png">
<link rel="apple-touch-icon" sizes="76x76" href="http://cdn.ink.sapo.pt/3.1.10/img/touch-icon-ipad.png">
<link rel="apple-touch-icon" sizes="120x120" href="http://cdn.ink.sapo.pt/3.1.10/img/touch-icon-iphone-retina.png">
<link rel="apple-touch-icon" sizes="152x152" href="http://cdn.ink.sapo.pt/3.1.10/img/touch-icon-ipad-retina.png">
<link rel="apple-touch-startup-image" href="http://cdn.ink.sapo.pt/3.1.10/img/splash.320x460.png" media="screen and (min-device-width: 200px) and (max-device-width: 320px) and (orientation:portrait)">
<link rel="apple-touch-startup-image" href="http://cdn.ink.sapo.pt/3.1.10/img/splash.768x1004.png" media="screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:portrait)">
<link rel="apple-touch-startup-image" href="http://cdn.ink.sapo.pt/3.1.10/img/splash.1024x748.png" media="screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:landscape)">
<!-- load Ink's css from the cdn -->
<link rel="stylesheet" type="text/css" href="http://cdn.ink.sapo.pt/3.1.10/css/ink-flex.min.css">
<link rel="stylesheet" type="text/css" href="http://cdn.ink.sapo.pt/3.1.10/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>">
<!-- load Ink's javascript files from the cdn -->
<script type="text/javascript" src="http://cdn.ink.sapo.pt/3.1.10/js/holder.js"></script>
<script type="text/javascript" src="http://cdn.ink.sapo.pt/3.1.10/js/ink-all.min.js"></script>
<script type="text/javascript" src="http://cdn.ink.sapo.pt/3.1.10/js/autoload.js"></script>
This is part of my index.php: 这是我的index.php的一部分:
<?php get_header(); ?>
<form action="" class="ink-form">
<div class="ink-grid">
<div class="panel">
<div class="control-group append-button"></div>
<div class="control all-100">
<input type="text" name="s" placeholder="Search news...">
</div>
</div>
</div>
</form>
<div class="ink-grid vertical-space">
<div class="panel">
<h2>Recent News</h2>
<div id="car1" class="ink-carousel" data-space-after-last-slide="false" data-autoload="false">
<ul class="stage column-group half-gutters">
<?php while(have_posts()) : the_post(); ?>
<li class="slide xlarge-25 large-25 medium-33 small-50 tiny-100">
<?php the_post_thumbnail('news-thumb', array(
'class' => 'half-bottom-space')); ?>
<div class="description">
<h4 class="no-margin"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></h4>
<h5 class="slab"><?php the_time('F j, Y g:i a'); ?></h5>
<div class="excerpt"><?php the_excerpt(); ?></div>
</div>
</li>
<?php endwhile; ?>
</ul>
</div>
<nav id="p1" class="ink-navigation">
<ul class="pagination black">
</ul>
</nav>
</div>
<div class="panel ink-grid">
<div class="column-group">
<div class="all-50">
This is my single.php: 这是我的single.php:
<?php get_header(); ?>
<form action="" class="ink-form">
<div class="ink-grid">
<div class="panel">
<div class="control-group append-button"></div>
<div class="control all-100">
<input type="text" name="s" placeholder="Search news...">
</div>
</div>
</div>
</form>
<div class="ink-grid vertical-space">
<div class="panel">
<h2>Recent News</h2>
<div id="car1" class="ink-carousel" data-space-after-last-slide="false" data-autoload="false">
<ul class="stage column-group half-gutters">
<?php while(have_posts()) : the_post(); ?>
<li class="slide xlarge-25 large-25 medium-33 small-50 tiny-100">
<?php the_post_thumbnail('news-thumb', array(
'class' => 'half-bottom-space')); ?>
<div class="description">
<h4 class="no-margin"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></h4>
<h5 class="slab"><?php the_time('F j, Y g:i a'); ?></h5>
<div class="excerpt"><?php the_excerpt(); ?></div>
</div>
</li>
<?php endwhile; ?>
</ul>
</div>
<nav id="p1" class="ink-navigation">
<ul class="pagination black">
</ul>
</nav>
</div>
<div class="panel ink-grid">
<div class="column-group">
<div class="all-50">
use get_template_directory_uri()
instead of bloginfo()
使用
get_template_directory_uri()
代替bloginfo()
get_template_directory_uri() will give you current theme url upto style.css get_template_directory_uri()将为您提供当前的主题URL直至style.css
<link rel="stylesheet" type="text/css" href="<?php echo get_template_directory_uri().'/style.css'; ?>">
'stylesheet_url'
Displays the primary CSS (usually style.css) file URL of the active theme. 显示活动主题的主要CSS(通常为style.css)文件URL。 Consider echoing get_stylesheet_uri() instead.
请考虑回显get_stylesheet_uri()。
Fixed Issue code : 固定发行代码:
<link rel="stylesheet" type="text/css" href="<?php echo bloginfo('stylesheet_url'); ?>"> // you have to echo for print a path
Recommanded 推荐
get_stylesheet_uri() get_stylesheet_uri()
Retrieves the URI of current theme stylesheet. 检索当前主题样式表的URI。
Your code will be : 您的代码将是:
Replace this line 替换此行
<link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>">
with 与
<link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_directory_uri().'/style.css'?>">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.