自定义模板页眉不加载wordpress中的style.css

时间:2013-10-30 22:59:43

标签: php html wordpress

我在get_header();的自定义模板页面上调用标题,但是在没有使用style.css破坏网站的情况下加载标题。我注意到如果我将标题放在某些代码的顶部,样式表加载就好了,例如:

<?php
/*
    Template Name: Sample Template
*/

get_header();

//some code here

我需要在某些代码下面加载标题,因为我使用的是cookie,据我所知,应该在任何HTML之前生成Cookie。

1 个答案:

答案 0 :(得分:5)

请勿在{{1​​}}之上放置任何代码。相反,使用动作“挂钩”并在那里做一些工作。

例如,您可以使用get_header()这样的操作:

get_header

请参阅http://codex.wordpress.org/Plugin_API/Action_Reference/get_header

更多关于行动:http://codex.wordpress.org/Plugin_API

最初可能需要花一些时间来处理动作(和过滤器),但这些是WordPress中的关键概念,所以它绝对值得!