Home Forums Front-end Issues Taxonomy related query not working


Taxonomy related query not working

  • Hello,

    For all of my pages I have setup a taxonomy field using ACF, for which I can then select as ‘Home’, or something else like ‘News’.

    I have a custom post type ‘slides_post_type’ where for each new ‘slide’ I am selecting the relevant category, i.e. ‘Home’.

    The code I am using at present to output the slides is:

        $slides_category = get_field('slider_category');
        $args = array(-
    	'post_type' => 'slides_post_type',
    	'tax_query' => array(
    		'taxonomy' => 'category',
    		'field'    => 'slug',	
    		'terms'    => array( $slides_category ),
        $query = new WP_Query( $args );
        $my_secondary_loop = new WP_Query( $args );
        if( $my_secondary_loop->have_posts() ): while( $my_secondary_loop->have_posts() ): $my_secondary_loop->the_post(); ?>
    	// Post output here
        <?php endif; ?>
    <?php endwhile; ?>

    Where my page is set to ‘Home’ and my slides are set to the same category this code however is not outputting anything.

    Can anybody please help? I appreciate any support you can provide.

Viewing 1 post (of 1 total)

The topic ‘Taxonomy related query not working’ is closed to new replies.