Archive Page – Display two connected posts, different taxonomies
-
I think this plugin might be the solution I am looking for but I can’t seem to get it functional.
I am building a tickets website and have 2 different taxonomies.
taxonomy1 = product (date, price and & opposing team info)
taxonomy2 = seatsI would like to display the list of ‘products’ on one side and the list of associated ‘seats’ on the other side. (approx. 4 seats to 50-100 ‘products’)
I have tried for hours to make the code work as given in each_connected and basic usage. But I either get a blank screen or nothing. I am confused as to whether this code gets nested within the regular loop or is a stand alone loop of it’s own.
The connection itself is registered and shows in the admin dashboard.
What I have tried so far….
<?php if ( have_posts() ) : ?> <div class="ticket-details row"> <?php while ( have_posts() ) : the_post(); ?> <?php the_title(); ?> <?php $connected = new WP_Query( array( 'connected_type' => 'product_to_seats', 'connected_items' => $post, ) ); if ( $connected->have_posts() ) : ?> ?> <?php while ( $connected->have_posts() ) : $connected->the_post(); ?> <?php the_field('tax-row'); ?> <?php endwhile; ?> <?php wp_reset_postdata(); endif; ?> <?php endwhile; ?> <?php else : ?> <?php endif; ?> </div> <?php wp_reset_postdata(); ?><?php if ( have_posts() ) : ?> <div class="ticket-details row"> <?php while ( have_posts() ) : the_post(); ?> <?php the_title(); ?> <?php // Find connected pages (for all posts) p2p_type( 'posts_to_posts' )->each_connected( $wp_query ); ?> <?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?> <?php the_title(); ?> <?php // Display connected pages echo '<p>Related pages:</p>'; foreach ( $post->connected as $post ) : setup_postdata( $post ); the_title(); echo '<p>Connection ID: ' . $post->p2p_id . '</p>'; ... endforeach; wp_reset_postdata(); // set $post back to original post ?> <?php endwhile; ?> <?php endwhile; ?> <?php else : ?> <?php endif; ?> </div> <?php wp_reset_postdata(); ?>I’ve also tried without the main query, with product_to_seats, and a thousand other different tweaks hoping to get something to display, but haven’t been successful. Can someone give me some direction please?
The topic ‘Archive Page – Display two connected posts, different taxonomies’ is closed to new replies.