当我尝试在我的wordpress header.php文件中添加我的theme.css时,page.php无效

时间:2017-09-24 05:46:57

标签: php wordpress woocommerce wordpress-theming fixed

在我的header.php中,我为CSS添加了这段代码:

<link id="theme" rel="stylesheet" href="<?php echo esc_url(get_template_directory_uri()); ?>/css/theme.css">

当我从header.php中删除此代码时,我的page.php正在运行,但没有正确显示文本和图像。 (CSS不起作用)像这样:

image: when css not add in my header.php

但是当我在header.php文件中添加此代码然后在我的page.php文件中,我看到一个空白页面。没有文字或图像显示。像这样:

Image: a blank page after add css in my header.php file

我如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

这不是最佳做法。为主题添加脚本和样式的正确方法是将它们排入functions.php文件中。

点击此链接一次: - https://developer.wordpress.org/themes/basics/including-css-javascript/