0
我试图在WordPress中获取标签描述并显示,但没有成功。我在下面评论了我添加的内容以获取标签描述。获取标签描述并在WordPress中显示
<?php
$q_categories = $_GET['categories'];
$q_tags = $_GET['tags'];
$term_id = 26;
$taxonomy_name = 'tags';
$termchildren = get_term_children($term_id, $taxonomy_name);
$description = tag_description(); //NOT WORKING
foreach ($termchildren as $child) {
$term = get_term_by('id', $child, $taxonomy_name, $description);
$tag_image = get_field('tag_image', $term);
$show_on_landing_page = get_field('show_on_landing_page', $term);
if ($show_on_landing_page) { ?>
<div class="box three columns">
<div class="box-content slidedown">
<? if(!empty($tag_image)): ?><img src="<? echo the_field('tag_image', $term); ?>" class="cover cat-img" /><?php endif; ?>
<div class="details">
<div class="details-container">
<h4><? echo $term->name; //NOT WORKING ?></h4>
<p><? echo $term->description; ?></p>
<a href="?tags=<? echo $term->slug; ?>" class="btn hvr-bounce-to-right">View Work</a>
</div>
</div>
</div>
</div>
<? } ?>
<? } ?>
您尚未将标记ID传递给该函数......它无法知道您想要的标记描述。 – rnevius
我需要它来为父标签26的所有子标签工作 – Amesey