更改自定义 Wordpress 集成页面的标题 [英] changing the title of a custom Wordpress integrated page
问题描述
当我需要向基于 Wordpress 的站点添加自定义页面时,我总是首先加载主题的标题:
When I need to add a custom page to Wordpress based site I always load the theme's header first:
<?php
require('../wp-blog-header.php');
include('../wp-content/themes/mytheme/header.php');
?>
不幸的是,由于 header.php 中的这段代码,每个自定义页面都会获得相同的标题(博客名称):
Unfortunately then every custom page gets the same title (the blog's name) due to this code in header.php:
<head>
<title><?php if(is_home()) { bloginfo('name');} else { bloginfo('name'); echo ' | '; the_title(); } ?></title>
更改此页面标题的最佳方法是什么?
What would be the best way to change this page title?
- 在加载标题之前是否有一个 wordpress 方法可以调用来改变
the_title()
的返回值? - 我是否应该更改 header.php 调用,以便它检查是否有先前为我的标题定义的自定义值?
谢谢,
推荐答案
其实你可以这样看你的头代码:
Actually you can look at your header code like this:
<?php
if (is_home()) {
bloginfo('name');
} else {
bloginfo('name'); echo ' | '; the_title();
} ?>
翻译:如果(这是你的家)然后打印博客的名字.否则,打印博客的名称,一个 |栏和页面/帖子标题.
Translating: if (it is your home) then print the blog's name. Else, print the blog's name, a | bar and the page/post title.
它是否只在自定义页面上打印博客名称,还是正确执行?
Is it printing ONLY the blog's name on custom pages or is it performing correctly?
这篇关于更改自定义 Wordpress 集成页面的标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!