我继承了一个包含自定义帖子类型(城市)的网站。由于一些奇怪的URL重写和重定向,SEO插件将无法在这些页面上工作。如何在WordPress中为标题标签添加分类术语?
这个自定义文章类型有一个分类(国家),我需要插入状态名到标题标签在我的header.php。我试过以下,但无济于事:
<title>Log Cabin Rentals in <?php single_term_title(); ?> - Find Your Dream Vacation Rental in <?php single_term_title(); ?></title>
我也试过:
<?php
$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
echo '<title>Cash for Gold Near ' . $term->name . ' - Find Gold Buyers Near ' . $term->name .'</title>';
echo '<meta name="description" content="Looking for cash for gold near ' . $term->name . '? Our cash for gold directory helps you find reputable local gold buyers and pawnshops near ' . $term->name . ', as well as info on how to earn the most cash for gold.">';
?>
我在做什么错?
非常感谢!
辛西娅
缺货的好奇你是否尝试过single_cat_title()或single_tax_title()来代替?如果没有看到自定义帖子类型设置,很难确切地说出你需要哪个。 –
你会得到什么?什么?没有?任何错误或警告? 你可以尝试var_dump($ term);并粘贴结果?我有一种感觉,这个物体可能是空的。 – Spartacus