[英]Change Woocommerce Product Title
If 如果
test.com/shop , title is Products | test.com/shop,标题为Products | ABC
ABC
so 所以
test.com/shop/i_am_a_product , title is I am a product | test.com/shop/i_am_a_product,标题是我是产品| ABC
ABC
Now , i want change this Title to I am a product | 现在,我想将此标题更改为“ 我是产品”。 ABCDEF .
ABCDEF 。
How to do ? 怎么做 ? just add something to title ( Keep index title to ABC ).
只需在标题中添加一些内容即可(将索引标题保留在ABC中)。
Sorry my english , can anyone help me ? 对不起,我的英语,有人可以帮我吗?
From your question I'm assuming that you want to modify the page title in the single product's page. 根据您的问题,我假设您要修改单个产品页面中的页面标题。 To modify the page title open your theme's
header.php
file. 要修改页面标题,请打开主题的
header.php
文件。
I'm assuming the current <title></title>
tag is like following- 我假设当前的
<title></title>
标签类似于以下内容-
<title
<?php wp_title( '|', true, 'right' ); ?>
<?php bloginfo('name')?>
</title>
Woocommerce provides a function is_product()
to check that if the current page is the single product page. Woocommerce提供了一个
is_product()
函数来检查当前页面是否为单个产品页面。 Use it as following- 如下使用它-
<title
<?php wp_title( '|', true, 'right' ); ?>
<?php
if( is_product() ){
// use your own code here, like ABCDEF
// this part will only show up in a single product page
}
else{
bloginfo('name'); // this is the name of your website.
// use your code to display title in all other pages.
}
</title>
Hope this might be helpful. 希望这会有所帮助。
Thanks. 谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.