Wordpress在自定义页面

时间:2017-02-02 18:32:39

标签: php wordpress

我正在尝试创建完全自定义页面,但使用相同的功能在WP中创建页眉和页脚。 我在我的页面上有这个

<?php
include("../wp-blog-header.php");
get_header();
?>
<title>My Custom Title Here</title>
<?php
wp_head();
get_footer();
?>

页面显示正常,但当我尝试在<title>My Custom Title Here</title>之后添加get_header()时,我会在页面来源中将其标记为Page not found &#8211; My Custom Title

如何设置自定义页面标题?我的意思是在页面加载后标题应为<title>My Custom Title Here</title>

1 个答案:

答案 0 :(得分:1)

也许不理想,但我在紧要关头完成了以下工作。使用一些额外的逻辑,你可以将它添加到你的functions.php,但如果你真的只需要一个页面,我只需要在调用import pprint _escape = dict((q, dict((c, unicode(repr(chr(c)))[1:-1]) for c in range(32) + [ord('\\')] + range(128, 161), **{ord(q): u'\\' + q})) for q in ["'", '"']) class MyPrettyPrinter(pprint.PrettyPrinter): def format(self, object, context, maxlevels, level): if type(object) is unicode: q = "'" if "'" not in object or '"' in object \ else '"' return ("u" + q + object.translate(_escape[q]) + q, True, False) return pprint.PrettyPrinter.format( self, object, context, maxlevels, level) pp = MyPrettyPrinter() s = u'\u7279\u6717\u666e\u5973\u513f\u4f0a\u4e07\u5361\u5230\u4e2d\u56fd\u5927\u4f7f\u9986\u8d3a\u65b0\u5e74' print(s) data = { u'title' : s } pp.pprint(data) 之前在该特定文件中包含过滤器。

get_header()
相关问题