admin管理员组文章数量:1332383
I'm developing a theme for Themeforest and one of their requirements is about the tag. Themeforest states their requirement as follows:
The theme must let WordPress add and manage the title. This is done by adding add_theme_support( 'title-tag' );
to functions.php instead of using wp_title()
in the document head.
The current output is on the home page: 'Site title - Site tagline
'. On other pages it is 'Post or page title - Site tagline
'.
The separator is '-'. Can anyone give an example of a filter for this, so that I can change the separator to '|' or a character of my choice?
Many thanks in advance!
I'm developing a theme for Themeforest and one of their requirements is about the tag. Themeforest states their requirement as follows:
The theme must let WordPress add and manage the title. This is done by adding add_theme_support( 'title-tag' );
to functions.php instead of using wp_title()
in the document head.
The current output is on the home page: 'Site title - Site tagline
'. On other pages it is 'Post or page title - Site tagline
'.
The separator is '-'. Can anyone give an example of a filter for this, so that I can change the separator to '|' or a character of my choice?
Many thanks in advance!
Share Improve this question edited Jul 6, 2020 at 13:02 ralphjsmit asked Jul 6, 2020 at 11:55 ralphjsmitralphjsmit 4026 silver badges23 bronze badges 9 | Show 4 more comments1 Answer
Reset to default 2You use the document_title_separator filter.
So in your case:
<?php
function theme_prefix_filter_document_title_separator() {
return '|';
}
add_filter( 'document_title_separator', 'theme_prefix_filter_document_title_separator' );
?>
本文标签: Theme support title taghow to replace the default WP separator (with a filter)
版权声明:本文标题:Theme support title tag - how to replace the default WP separator (with a filter)? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742288387a2447343.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
<title>
tag entirely. WordPress will output it at<?php wp_head(); ?>
. – Jacob Peattie Commented Jul 6, 2020 at 12:00<title>
tag, not just thewp_title()
part. Sobloginfo()
should be removed to, as well as the HTML. – Jacob Peattie Commented Jul 6, 2020 at 12:10