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' );
?>
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742288387a4415736.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