Created
December 28, 2014 13:44
-
-
Save markbain/c67cbfa796c3f0bf1a17 to your computer and use it in GitHub Desktop.
WordPress snippet: show connected items, in this case "reviews".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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