Skip to content

Instantly share code, notes, and snippets.

@markbain
Created December 28, 2014 13:44
Show Gist options
  • Select an option

  • Save markbain/c67cbfa796c3f0bf1a17 to your computer and use it in GitHub Desktop.

Select an option

Save markbain/c67cbfa796c3f0bf1a17 to your computer and use it in GitHub Desktop.
WordPress snippet: show connected items, in this case "reviews".
<?php
$connected_reviews = new WP_Query( array(
'connected_type' => 'nice_stuff',
'connected_items' => get_queried_object(),
'nopaging' => true,
) );
if ( is_singular( 'portfolio_item' ) && $connected_reviews->have_posts() ) : ?>
<?php while ( $connected_reviews->have_posts() ) : $connected_reviews->the_post();
// Reviews
$reviewer_name = get_post_meta($post->ID, 'reviewer_name', true);
$reviewer_link = get_post_meta($post->ID, 'reviewer_link', true);
$reviewer_description = get_post_meta($post->ID, 'reviewer_description', true);
?>
<?php the_title(); ?>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php endif; // have_posts ?>
<?php // is_ singular ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment