这是我的问题:
我有一个 WordPress 网站,我在其中创建了一个自定义帖子类型(名为“collections
”),每个集合都有一篇文章。
我想在自定义帖子类型的存档页面中添加元描述
www.thesitename.com/collections
我在 header.php
中尝试过这个位:
<?php
if (is_category('collections'))
{
?>
<meta name="description" content="the description">
<?php } ?>
但是源码里什么都没有...
我在 Yoast SEO 中到处都看过,但我找不到解决方案,甚至在谷歌上也找不到。
你有想法吗?
最佳答案
If you want to check
post_type
archive page then you have to useis_post_type_archive()
and if you want to check the archive page of custompost_type
category then you have to useis_tax()
if (is_post_type_archive('collections'))
{
echo 'This is the collections post_type archive page';
}
附加信息但与您的问题没有直接关系。
if (is_tax('collections_cat', 'cat-1'))//<-- Replace it with your taxonomy, term name
{
echo 'This is the collections post_type, category cat 1 archive page';
}
希望这对您有所帮助!
关于php - 在 WordPress 中为自定义帖子类型存档添加元描述,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42896558/