我有一个分类法叫做schedule_day_taxonomy
add_action( \'init\', \'schedule_day_tax_func\' );
function schedule_day_tax_func() {
register_taxonomy(
\'schedule_day_taxonomy\',
\'schedule\',
array(
\'hierarchical\' => true,
\'label\' => \'Day\',
\'query_var\' => true,
\'orderby\' => \'ID\', /*
)
);
}
还有这个
taxonomy
仅分配给某个自定义职位类型。。调用
schedule
add_action( \'init\', \'schedule_func\' );
function schedule_func(){
register_post_type(\'schedule\', array(
\'label\' => \'TV schedule\',
\'show_ui\' => true,
\'supports\' => array(\'title\', \'thumbnail\'),
\'public\' => true,
\'publicly_queryable\' => true,
\'rewrite\' => array( \'slug\' => \'show-schedule\' ),
\'labels\' => array (
\'name\' => \'TV schedule\',
\'singular_name\' => \'TV schedule\',
\'menu_name\' => \'TV Schedules\'
),
) );
}
现在我想把邮件发过去
terms
在分类法下创建
schedule_day_taxonomy
仅为自定义职位类型分配
schedule
我创建了两个术语monday
和tuesday
如果是在规定期限内,我正在努力获得所有的职位tuesday
. 所以我尝试了以下代码:
<ul id="home-sche-list">
<?php
$args = array( \'post_type\' => \'schedule\', \'posts_per_page\' => 15, \'tax_query\' => array(
array(
\'taxonomy\' => \'schedule_day_taxonomy\',
\'field\' => \'tuesday\',
\'terms\' => \'tuesday\'
)
)
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
$image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id,\'schedule_home_page_thumb\', true);
$terms = get_the_terms( $post->ID, \'schedule_taxonomy\' );
?>
<li>
<a href="<?php the_permalink(); ?>" target="_blank" class="wrapper-container">
<div class="sche-thumb-con">
<span>
<img src="<?php echo $image_url[0]; ?>" class="video-thumb hoverZoomLink" alt=""/>
<div class="new-cat">
<?php
foreach($terms as $term) {
echo $term->name;
} ?>
</div>
</span>
</div>
<div class="sche-txt-wrapper">
<div class="schedule-prog"><?php the_title(); ?></div>
<div class="schedule-time evening">
<?php
$terms = get_the_terms( $post->ID, \'schedule_time_taxonomy\' );
foreach($terms as $term) {
echo $term->name;
}
?>
</div>
</div>
</a>
</li>
<?php endwhile; ?>
</ul>
但我没有收到显示的帖子。我有一个职位分配给这个学期
tuesday
.
Admin address bar
我做错了什么?如果我把这篇文章分配给另外两个分类法(自定义),会有影响吗?我还有两个分类法,它们被分配给了这篇文章。