我正在制作关于电影的网站。分类法用于演员。例如:
如何制作?这是taxonomy.php的代码:
<?php get_header(); ?>
<div class="module">
<?php get_template_part('inc/parts/sidebar'); ?>
<div class="content">
<header><h1><?php printf( __( '%s', 'mundothemes' ), '' . single_tag_title( '', false ) . '' ); ?></h1></header>
<div class="<?php if(is_tax('dtquality')) { echo 'slider'; } else { echo 'items'; } ?>">
<?php if (have_posts()) :while (have_posts()) : the_post(); ?>
<?php if(is_tax('dtquality')) { get_template_part('inc/parts/item_b'); } else { get_template_part('inc/parts/item'); } ?>
<?php endwhile; endif; ?>
</div>
<?php if (function_exists("pagination")) { pagination($additional_loop->max_num_pages); } ?>
</div>
</div>
<?php get_footer(); ?>
答案 0 :(得分:2)
这应该适用于<?php echo term_description(); ?>
另请参阅https://codex.wordpress.org/Function_Reference/term_description,您还可以在其中阅读有关两个可选参数$term_id
和$taxonomy
答案 1 :(得分:1)
您可以使用方法term_description
echo term_description($term_id, "your-taxonomy");
答案 2 :(得分:0)
123是术语ID。
$data = get_term(123)->description;
print_R($data);
答案 3 :(得分:0)
每个分类法都有唯一的ID,例如“ course_teachers”。所以我们像这样来抓它:
get_the_terms($post->ID , 'course_teachers');
在此示例中,我们满足了低等分类法的第一项并将其存储在变量中。就像:
$course_teacher = get_the_terms($post->ID , 'course_teachers')[0];
现在我们需要掌握一下描述:
$teacher_description = term_description( $course_teacher, 'course_teachers' );
最后,在网页上打印说明:
echo $teacher_description;
注意:如果出现类似错误(变量$ post不存在)。不用担心,只需在代码上方添加以下代码即可:
global $post;
如果您使用的是“循环”。您需要在循环内编写$ teacher_description变量。
获取其他数据:
->分类名称
$teacher_name = $course_teacher->name;
->分类档案URL
$teacher_archive_url = get_term_link( $course_teacher, 'course_teachers' );
我不是后端开发人员,这是我的全部知识。我希望这会对某人有所帮助。
答案 4 :(得分:0)
显示类别说明:
<?php
the_archive_description( '<div class="taxonomy-description">', '</div>' );
?>
https://developer.wordpress.org/reference/functions/the_archive_description/