我在get_header();
的自定义模板页面上调用标题,但是在没有使用style.css破坏网站的情况下加载标题。我注意到如果我将标题放在某些代码的顶部,样式表加载就好了,例如:
<?php
/*
Template Name: Sample Template
*/
get_header();
//some code here
我需要在某些代码下面加载标题,因为我使用的是cookie,据我所知,应该在任何HTML之前生成Cookie。
答案 0 :(得分:5)
请勿在{{1}}之上放置任何代码。相反,使用动作“挂钩”并在那里做一些工作。
例如,您可以使用get_header()
这样的操作:
get_header
请参阅http://codex.wordpress.org/Plugin_API/Action_Reference/get_header
更多关于行动:http://codex.wordpress.org/Plugin_API
最初可能需要花一些时间来处理动作(和过滤器),但这些是WordPress中的关键概念,所以它绝对值得!