Community Forums › Forums › Archived Forums › Design Tips and Tricks › Running Multiple Loops
Tagged: Custom Post Type, custom taxonomy, multiple loops, secondary
- This topic has 1 reply, 2 voices, and was last updated 10 years, 9 months ago by Sridhar Katakam.
-
AuthorPosts
-
December 12, 2013 at 5:38 pm #78671thoughtwellMember
I cannot get my second loop to run on my single page template for my custom post type of video.
I'm trying to show the video up top, followed by the description. I achieved this using the_content()
What I want to do is hook into the genesis_after_loop and insert an output of 6 videos from the same category from that taxonomy.
This is what I have:
<?php /** * The custom Videos post type single post template */ /** Force full width content layout */ add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' ); remove_action('genesis_before_loop', 'genesis_do_breadcrumbs'); /** Remove the post info function */ remove_action( 'genesis_entry_header', 'genesis_post_info', 12 ); /** Add 'Case Study:'' text to Title: Thanks Adamcap.com: http://adamcap.com/code/filter-genesis-h1-post-titles-to-add-for-styling/ */ add_filter( 'genesis_post_title_output', 'vid_post_title_output', 15 ); function vid_post_title_output( $title ) { if ( is_singular() ) $title = sprintf( '<h1 class="entry-title"><span class="case-study">Case Study:</span> %s</h1>', apply_filters( 'genesis_post_title_text', get_the_title() ) ); return $title; } //* Remove the post content */ remove_action( 'genesis_entry_content', 'genesis_do_post_content' ); //* Add Post Content back in the way we want it done */ function smt_video_staging() { echo '<div class="video-feed">'; the_content(); echo '</div>'; } add_action( 'genesis_entry_content', 'smt_video_staging' ); /** Remove the post meta function */ remove_action( 'genesis_entry_footer', 'genesis_post_meta' ); /** Remove the author box on single posts */ remove_action( 'genesis_after_entry', 'genesis_do_author_box_single' ); /** Remove the comments template */ remove_action( 'genesis_after_entry', 'genesis_get_comments_template' ); /** Add Video Feed Output below single post */ function smt_video_feed_op() { wp_reset_query(); $otherVids = new WP_Query(); $otherVids -> query('posts_per_page=6&cat=136'); while ($otherVids->have_posts()) : $otherVids->the_post(); if ( has_post_thumbnail() ){ echo '<div class="videos-featured-image">'; echo '<a href="' . get_permalink() .'" title="' . the_title_attribute( 'echo=0' ) . '">'; echo get_the_post_thumbnail($thumbnail->ID, 'videos' ); echo '</a>'; echo '</div>'; endwhile; wp_reset_query(); } add_action( 'genesis_after_loop' , 'smt_video_feed_op'); genesis();
I'm no PHP programmer by a longshot, but I'm trying to learn and this is the best I've managed to come up w/ after extensive reading about loops, queries, etc. If I can even get this to 'crudely' output a feed, I can pretty much take it from there, but my page is not showing up w/ the above code. I have a reason to believe it's something to do with the if statement in my smt_video_feed_op() function (since that is what broke my page). Can ANYONE w/ some php gusto chime in to maybe point me in the right direction?
December 14, 2013 at 12:51 am #78997Sridhar KatakamParticipantcan be easily done using Views plugin. Not sure if you are fine with using a plugin for doing this though.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.