Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 简单的WordPress";可湿性粉剂“头”;行动钩_Php_Html_Css_Wordpress - Fatal编程技术网

Php 简单的WordPress";可湿性粉剂“头”;行动钩

Php 简单的WordPress";可湿性粉剂“头”;行动钩,php,html,css,wordpress,Php,Html,Css,Wordpress,有一个让我抓狂的问题,原因是它应该是一个非常简单的修复,基本上在我的“footer.php”文件中,我需要在“wp_head”钩子中添加一些CSS行。我期望的工作是: <?php function footer_widgets() { ?> <style type="text/css"> #footer { border-top:0 !important; margin-top:0 !important; padding-top:0 !import

有一个让我抓狂的问题,原因是它应该是一个非常简单的修复,基本上在我的“footer.php”文件中,我需要在“wp_head”钩子中添加一些CSS行。我期望的工作是:

<?php function footer_widgets() { ?>
<style type="text/css">
#footer {
    border-top:0 !important;
    margin-top:0 !important;
    padding-top:0 !important;
}
</style>
<?php } add_action('wp_head', 'footer_widgets');?>

#页脚{
边框顶部:0!重要;
页边距顶部:0!重要;
填充顶部:0!重要;
}
这没有任何作用,奇怪的是,如果我将钩子从“wp_头”更改为“wp_脚”,它将输出到该钩子,但这个需要在“wp_头”中

如果有人知道如何解决这个问题,我们将不胜感激。 干杯
Tom.

在普通页面上,您的footer.php只有在
wp\u head
运行之后才会包含在内。查看模板中的
get\u footer()
?这就是代码运行的时间。您需要将此代码包含在页面生命周期早期加载的文件中(例如functions.php)。

是否有任何理由将此代码包含在footer.php中?如果你把它放进你的functions.php文件中,它应该工作得很好。啊,我的错,当时我的脑子一片空白,为此干杯!