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
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.