Lọc bài viết theo url danh mục taxonomy wordpress
5 năm trước,
Code theme wordpress,
653 Lượt xem
Đây là Code lọc bài viết theo url danh mục taxonomy trong wordpress thành công 100%, các bạn áp dụng lọc theo danh mục mình thích, tùy biến code dễ dàng
<?php
$the_press = new WP_Query(array('post_type' => 'dich_vu','posts_per_page' => 10,
'tax_query' => array(
array (
'taxonomy' => 'chuyen_muc_dich_vu', // ten taxonomy
'field' => 'slug',
'terms' => 'dich-vu-thiet-ke',// ten url chuyen muc taxomy
)
),
));
// The Loop
while ($the_press->have_posts()) : $the_press->the_post();
?>
<div class="col-sm-4 boxtinok">
<div class="post-item-bv wow fadeInUp">
<div class="hinhdichvu">
<a href="<?php echo the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
</div>
<h5 class="post-title-gory"><a href="<?php echo the_permalink(); ?>"><?php the_title(); ?></a></h5>
<p class="excerpt-gory"><?php the_excerpt(); ?>
</p>
</div>
</div>
<?php endwhile; ?>
<?php wp_reset_postdata();?>
Nội dung
Xuất text theo danh mục theo slug
<?php $term = get_term_by('slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
if($term->slug == 'cho-thue')
{echo'aaaaaaaaa';}
?>





Bình luận trên facebook netweb.vn