Support

Account

Home Forums General Issues Filter Relationship query of 2 different post type Reply To: Filter Relationship query of 2 different post type

  • Hi @toniup

    Within your loop, you could use the get_post_type() to see which post type is the post is.

    You could then add a conditional. Something like:

    
    <?php
    $posts = get_field( 'relazioni_strutture' );
    if ( $posts ) : ?>
    	<?php foreach( $posts as $post) : ?>
    	<?php setup_postdata( $post ); ?>
    
    	<?php $post_type = get_post_type();
    	if( $post_type == 'Struttura' ):
    	?>
    
    		<?php the_title(); ?>
    
    	<?php endif; #$post_type ?>
    
    	<?php endforeach; ?>
    	<?php wp_reset_postdata(); ?>
    <?php endif; ?>
    

    May need tweaking but should get you underway