nyrngrs24
Forum Replies Created
Viewing 1 replies (of 1 total)
-
Forum: Plugins
In reply to: [Posts 2 Posts] Relationship with Custom Post TypesWelp, i got it working! I was confused. I was using too many post loops. It clicked the other night. I’m supposed to use the existing post loop to show related videos.
Thanks again for spending the time on this plugin and the great docs.
here is the new code if people want to see:
<section id="music" class="section clearfix"> <div class="dyContainer"> <div class="album_container"> <h3>Albums</h3> <div class="col1"> <?php $args = array( 'post_type' => 'discography' ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); ?> <div class="album_wrap"> <?php the_post_thumbnail(); ?> <h4><?php the_title(); ?></h4> <span class="year"><?php echo get('year'); ?></span> </div> <?php endwhile; ?> </div> <a href="https://itunes.apple.com/artist/eve/id108709" class="itunes_link"><span class="itunes_icon"></span>see all albums on iTunes</a> </div> <div class="album_content"> <h3>tracklist + Videos</h3> <span class="choose">select an album<br/> to learn more</span> <div class="col2"> <?php $args = array( 'post_type' => 'discography' ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); ?> <div class="album hide"> <h3><?php $title1 = the_title(); echo $title1; ?><span class="year"><?php echo get('year'); ?></span></h3> <div class="track_wrap"> <div class="track_list"> <ol> <?php $tracks = get_group('track'); foreach($tracks as $track){ echo '<li><a>'; echo $track['track_title'][1]; echo '<span>' . $track['track_title_additional'][1] . '</span>'; echo '</a></li>'; } ?> </ol> </div><!-- end track list --> <a href="#" class="itunes_link"><span class="itunes_icon"></span>see this album on iTunes</a> </div><!-- end track wrap --> <div class="videos_wrap"> <div class="videos"> <?php // Find connected videos $connected = new WP_Query( array( 'connected_type' => 'posts_to_posts', 'connected_items' => $post, 'nopaging' => true ) ); // Display connected videos echo '<ul>'; while ( $connected->have_posts() ) : $connected->the_post(); echo '<li><a rel="video" href="' . get('youtube_link') . '">'; echo the_post_thumbnail('video'); echo '</a></li>'; endwhile; echo '</ul>'; wp_reset_postdata(); // set $post back to original post ?> </div> <a target="_blank" class="youtube" href="https://www.youtube.com/user/EveVEVO">visit Eve's Youtube channel</a> </div><!-- end video wrap --> </div> <?php endwhile; ?> </div> </div><!-- end album content --> </div> </section>
Viewing 1 replies (of 1 total)