Nội dung

Lọc bài viết theo url danh mục taxonomy wordpress

4 năm trước, Code theme wordpress, 573 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();?>

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ài viết mới cập nhập

  • Hướng dẫn Plugin floating contact

    Hướng dẫn Plugin floating contact

    9 tháng trước, 332 Lượt xem

    Netweb xin hướng dẫn cách quản lý Plugin floating contact các bạn nhớ làm theo kỹ tường bước để plugin hoạt động Tính năng: Hiển…

  • Backup Yandex Mail

    Backup Yandex Mail

    11 tháng trước, 222 Lượt xem

    Khác với dịch vụ email theo tên của microsoft và google với chi phí đắt đỏ tầm 1tr/năm/1user, vì thế nên netweb khuyên dùng dịch…

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

Đam mê thiết kế web, kinh nghiệm 9 năm trong nghề thiết kế website, đang thiết kế web dạo tại netweb.vn, Callme: 08.9898.2526 (Mr Hải)