admin管理员组文章数量:1312936
I want to change the title of my archive page from "category" to "department" to get something like this: Department: Marketing. Where "department" is the archive page title and "Marketing" is the actual name. This is the code that I used:
add_filter( 'get_the_archive_title', function ( $title ) {
if( is_category() ) {
$title = 'department';
}
return $title;
});
But It hides the page name. When I use this code, I get only "Department" as a title and when I delete it, I get "category: department".
How to fix it?
I want to change the title of my archive page from "category" to "department" to get something like this: Department: Marketing. Where "department" is the archive page title and "Marketing" is the actual name. This is the code that I used:
add_filter( 'get_the_archive_title', function ( $title ) {
if( is_category() ) {
$title = 'department';
}
return $title;
});
But It hides the page name. When I use this code, I get only "Department" as a title and when I delete it, I get "category: department".
How to fix it?
Share Improve this question asked Jan 12, 2021 at 0:58 josephjoseph 135 bronze badges1 Answer
Reset to default 1You need to add the actual page title back in. Try this:
add_filter( 'get_the_archive_title', function ( $title ) {
if( is_category() ) {
$title = 'Department: '. single_cat_title( '', false );
}
return $title;
});
本文标签: theme developmenthow to make wordpress change the title and keep page name
版权声明:本文标题:theme development - how to make wordpress change the title and keep page name? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741842622a2400592.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论