编辑page.php,包含外部样式表

时间:2013-12-10 14:56:38

标签: php html css wordpress

我在page.php中添加了一个链接标记。 现在我想使用我自己的样式表,我尝试了以下但是没有成功:

<link rel="stylesheet" href="<?php bloginfo('iww/cms/css/description1.css'); ?>" type="text/css" media="screen" />
<div><a  class="atlwdg-trigger atlwdg-RIGHT" href="#">Feedback?</a></div>

请帮忙!

5 个答案:

答案 0 :(得分:1)

您只能使用bloginfo()函数中提供的选项 看到这里.. wordpress bloginfo

尝试这样的事情......

<link rel="stylesheet" href="<?php echo bloginfo('url').'iww/cms/css/description1.css'; ?>" type="text/css" media="screen" />
<div><a  class="atlwdg-trigger atlwdg-RIGHT" href="#">Feedback?</a></div>

答案 1 :(得分:1)

您可以在Wordpress bloginfo page上看到bloginfo功能。使用<?php echo bloginfo('stylesheet_directory'); ?>/the/rest/of/your/path.css

所以在你的header.php中替换它:

<link rel="stylesheet" href="<?php bloginfo('iww/cms/css/description1.css'); ?>" type="text/css" media="screen" />
<div><a  class="atlwdg-trigger atlwdg-RIGHT" href="#">Feedback?</a></div>

有了这个:

<link rel="stylesheet href="<?php bloginfo('stylesheet_directory'); ?>/iww/cms/css/description1.css" type="text/css" media="screen"


修改

'stylesheet_directory' displays the stylesheet directory URL of the active theme.

所以请检查你的网址。如果您访问您的网站并查看源代码,您可以轻松检查它。有<link rel="" href="" type="" media="" />标记。如果链接正确,请检查是否可以编辑另一个名称相同的文件。如果路径错误,请在header.php

中更正


编辑2:

我更新了<link>标记。如您所见,我删除了echo。那里不需要echo,它应该在没有echo的情况下工作(对我而言,它完美无缺)。

答案 2 :(得分:0)

在模板目录中编辑 header.php 而不是 page.php ,并在关闭head标记之前添加以下代码

<link rel="stylesheet" href="<?php bloginfo('url').'iww/cms/css/description1.css'; ?>" type="text/css" media="screen" />

答案 3 :(得分:0)

建议在标题部分包含css文件,以便打开header.php文件并添加此行以包含css文件

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

如果您的css文件路径是iww / cms / css / description1.css,那么请包含此行

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

答案 4 :(得分:0)

这段代码也很有用,试一试。它也会工作。

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

希望答案有所帮助!