【问题标题】:Where can i set the location of the css file in wordPress using php?我可以在哪里使用 php 在 wordPress 中设置 css 文件的位置?
【发布时间】:2010-08-03 10:32:03
【问题描述】:

我正在使用 wordpress 并试图链接到样式表:

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

它无法识别该链接标签,因为我认为 bloginfo('stylesheet_url') 部分无法正常工作。

在wordpress中哪里可以设置样式表url的位置?

【问题讨论】:

    标签: php wordpress stylesheet


    【解决方案1】:

    这是应该指定的:

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

    您指定正确,请确保您已将 CSS 文件放在 theme 文件夹的根目录中,并且 CSS 文件名为 style.css

    【讨论】:

    • 我做了,我把它命名为 style.css。这就是我感到困惑的原因。
    • @zeckdude:这很奇怪,唯一的区别是我没有指定media="screen"
    • css 文件的名称在哪里指定,还是必须始终命名为 style.css?
    • 还要确保 header.php 文件中有&lt;?php wp_head(); ?&gt;,index.php 文件或其他文件中有&lt;?php get_header(); ?&gt;
    【解决方案2】:

    对于那些希望将样式表放在 /css 等子目录中的人的另一种解决方案是使用 bloginfo('template_url') 而不是 bloginfo('stylesheet_url')

    在链接href内和PHP标签外附加目录和样式表名称

    例如:

     <link rel="stylesheet" 
    href="<?php bloginfo('template_url'); ?>/css/style.css" 
    media="screen" />
    

    If (OOPS=='where did my background images go') { 在样式表中添加图片引用的相对路径,即url(images/mybackground.jpg) 变为url(../images/mybackground.jpg) }

    【讨论】:

      猜你喜欢
      • 2016-12-20
      • 1970-01-01
      • 1970-01-01
      • 2015-06-10
      • 1970-01-01
      • 1970-01-01
      • 2013-07-07
      • 1970-01-01
      • 2019-05-27
      相关资源
      最近更新 更多