【发布时间】:2014-12-09 20:22:23
【问题描述】:
我正在使用以下函数来更改 wordpress 中的页面标题。它适用于单个页面 (page.php),但不适用于我的静态主页或单个帖子 (single.php)。
我需要进行哪些更改才能在整个网站上进行这项工作?
<?php
function wpse46249_filter_wp_title( $title ) {
$some_custom_title_content = 'This is added to title';
$custom_title = $title . $some_custom_title_content;
return $custom_title;
}
add_filter( 'wp_title', 'wpse46249_filter_wp_title' );
?>
【问题讨论】:
-
你想为所有帖子设置相同的页面标题吗?
-
@HelpingHands,没有。该代码在传入的原始
$title上附加了一些内容。 -
@user1609391...这听起来像是模板问题。
-
你能粘贴在
single.php上打印title的代码
标签: wordpress function page-title