• Hi, firstly thank you very much for this plugin. This has made my life so much easier.

    I am trying to show all posts that are assigned ‘news’ term from two custom taxonomies, ‘videos’ and ‘images’, and hence need to use the OR relation. That is show ‘news’ from ‘videos’ or show ‘news’ from ‘images’.
    This is not working:
    [display-posts post_type=”gallery” taxonomy=”videos” tax_term=”news” taxonomy_2=”images” tax_2_term=”news” tax_relation=”OR” wrapper=”ul” wrapper_class=”media-grid-ul” image_size=”medium” include_date=”true” date_format=”F j, Y”]
    If i check with a custom wp query like below , it shows me the posts

    add_shortcode('shortcode', 'test_fn');
    function test_fn() {
        $args = array(
            'post_type' => 'gallery',
        	'tax_query' => array(
        		'relation' => 'OR',
        		array(
        			'taxonomy' => 'videos',
                    'field' => 'slug',
        			'terms' => array( 'news' )
        		),
        		array(
        			'taxonomy' => 'images',
                    'field' => 'slug',
        			'terms' => array( 'news' )
        		)
        	)
        );
        $query = new WP_Query( $args );
        if ( $query->have_posts() ) :
        // The Loop
        while ( $query->have_posts() ) {
            $query->the_post();
        	echo '<li>' . get_the_title() . '</li>';
        }
        wp_reset_postdata();
        else:
            echo 'Sorry, no posts matched your criteria.';
        endif;
    }

    I even tried changing the default parameter from the plugin file from $tax_relation = ‘AND’; to $tax_relation = ‘OR’;

    https://ww.wp.xz.cn/plugins/display-posts-shortcode/

The topic ‘tax_relation not working?’ is closed to new replies.