chavewain
11/6/2015 - 8:31 AM

wordpress - query by category, taxonomy, slug

wordpress - query by category, taxonomy, slug

<?php

$args = array(
    'post_type' => 'tcp_product',
    'posts_per_page' => 12,
    
    // category by slug 
    'category_name' => 'categoru-slug'
    
    // for custom category
    'tax_query' => array(
        array(
            'taxonomy' => 'tcp_product_taxonomy',
            'field' => 'slug',
            'terms' => 'your-cat-slug'
        )
     )
);

$posts = get_posts( $args );
     foreach( $posts as $post ): setup_postdata($post);
?>

<?php the_title(); ?>

<?php endforeach; ?>