Forum Replies Created

Viewing 15 replies - 1 through 15 (of 33 total)
  • Thread Starter janemig

    (@janemig)

    Anyone??

    Thread Starter janemig

    (@janemig)

    Do I need to create a taxonomy template file, i.e. taxonomy-event-names.php? And if so, what goes in it?

    Thread Starter janemig

    (@janemig)

    Here is my speakers query statement, in case I need to ‘blend’ anything into it:

    <?php $temp = $wp_query;
    					$speakers = new WP_Query( array(
    						'post_type' => 'speakers',
    						'paged'=>$paged,
    	                     'orderby'=>'title',
    	                     'order'=>'ASC'
                          ) ); ?>	
    
    					<?php if ( $speakers->have_posts() ) : while ( $speakers->have_posts() ) :  $speakers->the_post(); ?>

    Thread Starter janemig

    (@janemig)

    And, to the moderator who opened up the wonderful world of ‘new WP_Query’ to me. Give a man a fish and he’ll eat for a day. Give a man a fishing pole and he’ll eat for a lifetime. Thanks for the fishing pole, Alchymyth.

    Thread Starter janemig

    (@janemig)

    Which, of course, leads me to the query: How can you nest a loop of a custom post that HAS an archive into another loop? Sigh. This may be a query for another day…

    Nonetheless, here is the final code, I hope it can help anyone who’s in a jam:

    <?php
    /**
    *Template Name: Single Events
     */
    ?>
    	<?php get_header(); ?>
    
    	 	<div>
    
    	 	<?php if ( have_posts() ): ?>
    
    		       <?php while (have_posts()) : the_post();?><!-- begin events loop -->       
    
    				<article>
    
    					<!-- Events content here -->
    
    			      <!-- Then query for Speakers: -->
    			       <?php $temp = $wp_query;
    					$speakers = new WP_Query( array(
    						'post_type' => 'speakers',
    						'paged'=>$paged,
    	                     'orderby'=>'title',
    	                     'order'=>'ASC'
                          ) ); ?>	
    
    						<?php if ( $speakers->have_posts() ) : while ( $speakers->have_posts() ) :  $speakers->the_post(); ?> 
    
    				           <div class="speakerbio clearfix" id="post-<?php the_ID(); ?>">
    	                <div class="left">
    	                    <a href="<?php esc_url( the_permalink() ); ?>"><?php the_post_thumbnail(); ?></a>
    	                </div>
    
    	                <div class="right">
    
    	                    <h3><?php the_title(); ?>   <a href="#top"><i class="fa fa-caret-up"></i></a></h3>
    	                    <div class="sptitle"><b><?php the_field('speaker_title'); ?></b></div>
    
    	                    <?php the_field('speaker_bio_text'); ?>
    	                </div>
    
    	            </div> <!-- END speakerbio -->
    
    			           <?php endwhile;
    				    endif;
    				    $speakers->reset_postdata();
    					$wp_query = $temp; ?>
    					<!-- End speaker query and reset the events post data-->
    
    					<!-- Events content here -->
    
            	    </article>
    
    					<?php endwhile; ?>
    
    				<?php endif; ?>
    
    	 	</div>
    
    	 	<?php get_footer(); ?>
    Thread Starter janemig

    (@janemig)

    I found the answer! The ‘speakers’ custom post type declared Has-Archive as True, but it should be FALSE because it’s only being displayed on the events page as a list! So I changed has archive to false and it works!

    Thread Starter janemig

    (@janemig)

    Ok, I realized that placing that query code into the single-events.php only made it query the event posts all over again and return the latest 1. Thus, my getting only 1 post (the latest one) on that single page. So I took it out.

    And what I’m still left with is figuring out why the nesting of the speakers loop isn’t returning speakers, but is returning a list of my other custom posts and pages, with the styling of the speakers custom post type. Does that shake anything loose?

    Thread Starter janemig

    (@janemig)

    Hold the phone! I just added a few events and when I click any one of them to get to the main event page, only the last post that was created displays, no others. I tried adding wp_reset_query() at the end of the single-events.php page, but it doesn’t resolve it. Any clues?

    Thread Starter janemig

    (@janemig)

    Yay, I found the missing piece of code. I put this query right before my original loop and voila it all works! Here’s the code for anyone who’s in a jam:

    <?php query_posts(‘post_type=events&posts_per_page= -1’); ?>

    (you would substitute ‘events’ with whatever your custom post type name is. Use that with the wonderful code that wonderful Alchymyth was so generous to provide and you’re off and running with nested custom loops! Woohoo!

    Many thanks again to you, Alchymyth!!!

    Thread Starter janemig

    (@janemig)

    Do I have too many endifs and endwhiles in there? I’ve tried every combination, taking each out one by one, repositioning them, etc. Should the original query be something other than an ordinary loop?

    Thread Starter janemig

    (@janemig)

    Also, how would I get the speakers nav menu to display in alphabetical order?

    Thread Starter janemig

    (@janemig)

    Note, it uses loop code from the Advanced Custom Fields plugin. Could that be conflicting? Actually, I tried taking that code out, but it didn’t fix it.

    Thread Starter janemig

    (@janemig)

    Hi Alchymyth,

    It is ‘speakers’.

    I just put the code in pastebin: https://pastebin.com/gCYZBNuw

    This is a custom build, using Starkers foundation as a base. It’s very pared down. Do you need the archive-speakers.php or single-speakers.php code?

    Thread Starter janemig

    (@janemig)

    That seems so perfect!! You are so kind to help! I’m using the code and it’s still not behaving. It’s actually puling in a different custom post type, not speakers, which is odd. Question: I created an archive-speaker.php and a single-speaker.php for the cpt, Is that interfering in some way, should I not include those files since I’m only placing the speakers on the events page?

    Thread Starter janemig

    (@janemig)

    Thanks so much, I tried it but it’s not working. It makes total sense though! Does the first loop have to use WP_Query as well?

Viewing 15 replies - 1 through 15 (of 33 total)