我正试图从帖子和链接中获取分类。但是,链接必须来自其他自定义帖子“导演”,而分类法必须来自其他自定义帖子类型...我可以通常使用其他代码获取分类法但是,我无法获得链接...
当我尝试使用此代码时,我在页面上什么都没有...
此代码有什么问题?
<h6 class="box-title"><?php _e( 'Directed by:', 'listingpress' ); ?></h6>
<div class="director-box-inner">
<?php
$taxonomy ='mydirectors';
$term_lists = get_the_terms($post->ID, $taxonomy);
foreach ($term_lists as $termlist):
$name_term= $termlist->slug;
$argsdirectors = array(
'post_type' => 'directors',
'name' => $name_term
);
$loop = new WP_Query($argsdirectors);
if ( $loop->have_posts() ) :
while($loop->have_posts()): $loop->the_post();
?>
<div class="agent-card">
<a href="<?php the_permalink() ?>" class="agent-avatar-container">
<?php if(has_post_thumbnail()){
the_post_thumbnail();
}else{?>
<img src="<?php echo get_stylesheet_directory_uri().'/images/profil.png';?>"/>
<?php }
?>
</a>
<div class="agent-card-info">
<div class="agent-card-info-inner">
<h6 class="agent-card-name">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
</h6>
</div>
</div>
</div>
<a href="<?php the_permalink() ?>" class="button icon-button icon-agent director-profile-buton"><?php _e( 'View Profile', 'listingpress' ); ?></a>
<div class="clearfix"></div>
<?php
endwhile;
endif;
endforeach;
wp_reset_query();
?>
</div>