• Hello,

    I am working on my first theme from scratch and I encountered an issue while retrieving some posts linked to a taxonomy. Basically, I have some posts that are linked to a category news (seven posts). Then two of them are linked also to a custom taxonomy called ‘sliderType’ which has a category called Big Slider Home. When I try to retrieve all the posts linked to that taxonomy I somehow get all the posts from the database.

    This is the code of the taxonomy..
    add_action( 'init', 'create_cat_slider' );

    function create_cat_slider() {
    register_taxonomy(
    'sliderType','post',
    array(
    'label' => __( 'Slider' ),
    'hierarchical' => true,
    )
    );
    }

    .. and these are some versions of the loop

    $args = array(
    ‘taxonomy’ => ‘sliderType’
    );
    $custom_query = new WP_Query( $args );
    echo $custom_query->post_count;
    if($custom_query->have_posts())
    //rest of the loop

    OR

    $custom_query = new WP_Query( array( ‘post_type=post&cat=10’ ) );
    echo $custom_query->post_count;
    if($custom_query->have_posts()) :
    //rest of the loop

    I even tried some variations with tax_query in the array ( and I know it has to be an array in an array).

    I have no idea what am I missing and I would be grateful if anyone could help me deal with this issue.

    Cheers

The topic ‘WP Query Taxonomy Posts’ is closed to new replies.