[Plugin: Posts 2 Posts] Using p2p_get_meta in widget sidebar
-
I am trying to list data using the Executable PHP Widget by Otto to display php in a sidebar. The code works fine in a page template but only returns the post title in the sidebar. I don’t know if this has something to do with the PHP Widget plugin or P2P. Anyone have a suggestion on how to get it to work? Here is the code I am using:
<h2>Customer Relationship</h2> <?php // Find connected customers $connected = new WP_Query( array( 'connected_type' => 'posts_to_customers', 'connected_items' => get_queried_object(), 'nopaging' => true, 'connected_meta' => array( array( 'key' => 'customertype', 'value' => $customertype, ) ) ) ); // Display connected customers if ( $connected->have_posts() ) : ?> <ol> <?php while ( $connected->have_posts() ) : $connected->the_post(); ?> <li><a href="<?php the_permalink(); ?>"> <?php the_title();?> </a> </li> <?php $answer = p2p_get_meta($post->p2p_id, 'customertype', true); echo $answer; ?> <br/> <?php endwhile; ?> </ol> <?php // Prevent weirdness wp_reset_postdata(); endif; ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘[Plugin: Posts 2 Posts] Using p2p_get_meta in widget sidebar’ is closed to new replies.