Support » Plugin: Posts 2 Posts » [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>
    // Find connected customers
    $connected = new WP_Query( array(
      'connected_type' => 'posts_to_customers',
      'connected_items' => get_queried_object(),
      'nopaging' => true,
      'connected_meta' => array(
              'key' => 'customertype',
    		'value' => $customertype,
    ) );
    // Display connected customers
    if ( $connected->have_posts() ) :
    <?php while ( $connected->have_posts() ) : $connected->the_post(); ?>
    	<li><a href="<?php the_permalink(); ?>"> <?php the_title();?> </a>
    $answer = p2p_get_meta($post->p2p_id, 'customertype', true);
    echo $answer;
    <?php endwhile; ?>
    // Prevent weirdness

Viewing 1 replies (of 1 total)
  • Plugin Author scribu


    My guess is that you have to add global $post at the top of that code, but I could be wrong.

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Posts 2 Posts] Using p2p_get_meta in widget sidebar’ is closed to new replies.