1

我有一个基于 wordpress 的网站,当我在 localhost 上工作时,我使用这段代码来阅读 css:

<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>">
<!--[if IE]>
    <link rel="stylesheet" href="<?php echo get_stylesheet_directory()."/ie.css"; ?>" media="screen" type="text/css" />
<![endif]-->

如您所见,代码的第二部分是在我在 Internet Explorer 上查看网站时更改 css。碰巧这在 xampp 上运行良好,但现在,在迁移到在线服务器后,代码的第二部分不起作用,当我在 IE 上看到在线页面时,样式不适用。

任何提示为什么会发生这种情况?

4

1 回答 1

3
 <?php get_stylesheet_directory() ?>

返回一个绝对的服务器路径;

http://codex.wordpress.org/Function_Reference/get_stylesheet_directory

将您的代码更改为;

 <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>">
 <!--[if IE]>
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/ie.css"; ?>" media="screen" type="text/css" />
 <![endif]-->

它应该适合你。

于 2012-09-10T09:59:47.417 回答