[Plugin: Posts 2 Posts] Widget displays connected users, but 'basic usage' code does not.
-
I am incredibly confused – The ‘basic usage’ code doesn’t work when I try to put it in a sidebar area.
I need it to work through the code in the template rather than through a widget, as I need to be able to
1. limit it to display only one user when there are multiple connected, and,
2. if there is no connected user, to display the user connected to the posts parent.PLEASE tell me what I’m doing wrong! This is in my sidebar.php template file. It doesn’t seem to find any connected users.
$connected = new WP_Query( array( 'connected_type' => 'key_service_contact', 'connected_items' => get_queried_object(), 'nopaging' => true, ) ); // Display connected pages if ( $connected->have_posts() ) : ?> <h3>Key Contact</h3> <ul> <?php while ( $connected->have_posts() ) : $connected->the_post(); ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endwhile; ?> </ul> <?php // Prevent weirdness wp_reset_postdata(); endif;
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘[Plugin: Posts 2 Posts] Widget displays connected users, but 'basic usage' code does not.’ is closed to new replies.