【发布时间】:2021-03-09 02:56:24
【问题描述】:
我正在尝试在 WordPress 的自定义帖子类型中放置指向视频艺术家的链接。一切正常,但 term_id 没有迭代。
<?php
$args = array(
'post_type' => 'video',
'posts_per_page' => 4,
'taxonomy' => $term->name,
'number' => $term->term_id,
);
$q = new WP_Query( $args);
if ( $q->have_posts() ) {
while ( $q->have_posts() ) {
$q->the_post();
//Your template tags and markup like:
?>
<div class="card">
<div class="bg-img"><img alt="Norway" style="width:100%" src="<?php the_post_thumbnail( 'thumbnail' );?></div>
<div class="content">
<h4 style="color: green;"><?php the_title( ); ?></h4>
<h5 class="artist-name"><?php
$terms = get_terms( $args );
foreach( $terms as $term ){
echo '<div style="color: black;"><a href="' . esc_url( get_term_link( $term->slug, 'band' ) ) . '">' . esc_html( $term->name ) . " ". $term->term_id . '</a></div>';
} ?>
【问题讨论】:
标签: php wordpress wordpress-theming