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


Edit page.php , include external stylesheet

我在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>

请帮忙!

您只能使用bloginfo()函数中可用的选项请看这里。。wordpress博客信息

试试这样的。。。

<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>

您可以在Wordpress bloginfo页面上看到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的情况下工作(对我来说,它工作得很完美)。

在模板目录中编辑header.php代替page.php

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

这段代码也很有用,试试看。它也会起作用。

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

希望答案能有所帮助!

建议在标题部分包含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" />