[Plugin: Posts 2 Posts] Can't get connections with custom query
-
I am using a custom query on a page template to grab a random custom post type. Then within the loop of that custom query trying to grab the related posts. None of the related posts are showing up.
Here is my entire page template:
<?php get_header(); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div id="page-header"> <h1><?php the_title(); ?></h1> </div> <div id="main"> <section role="main"> <?php the_content(''); ?> <?php endwhile; endif; ?> <?php $the_query = new WP_Query( 'post_type=installations&posts_per_page=1' ); while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <div class="installation-content"> <?php the_content(); ?> <?php // Find connected pages $connected = new WP_Query( array( 'connected_type' => 'gallery_to_products', 'connected_items' => get_queried_object(), 'nopaging' => true ) ); // Display connected pages if ( $connected->have_posts() ) : p2p_list_posts( $connected, array( 'before_list' => '<h2>Products Used</h2><ul>', 'after_list' => '</ul>', 'before_item' => '<li>', 'after_item' => '</li>', ) ); endif; ?> </div> <?php endwhile; wp_reset_postdata(); ?> </section> </div> <?php get_footer(); ?>
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
The topic ‘[Plugin: Posts 2 Posts] Can't get connections with custom query’ is closed to new replies.