Advertisement
Guest User

posts 2 posts nested multiple

a guest
Feb 7th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.41 KB | None | 0 0
  1. <?php  $query2 = new WP_Query( array( 'post_type' => 'events', 'paged' => $paged ) );
  2.  if ( $query2->have_posts() ) : ?>
  3. <?php while ( $query2->have_posts() ) : $query2->the_post(); ?>
  4.         <h1><?php the_title(); ?></h1>
  5. <?php
  6.             //Platinum sponsors
  7.             $platinum = new WP_Query( array(
  8.               'connected_type' => 'sponsors_to_event', // the name of your connection type
  9.               'connected_items' => $post,
  10.               'nopaging' => true,
  11.               'cat'=>18,
  12.             ) );
  13.              
  14.             // Display connected sponsors
  15.             if ( $platinum->have_posts() ) : ?>
  16.                 <?php while ( $platinum->have_posts() ) : $platinum->the_post(); ?>
  17.                     <?php the_title(); ?>
  18.                 <?php endwhile; ?>
  19.                
  20.                 <?php
  21.                 // Prevent weirdness
  22.                 wp_reset_postdata();
  23.             endif;
  24.            
  25.                     //Platinum sponsors
  26.                     $gold = new WP_Query( array(
  27.                       'connected_type' => 'sponsors_to_event',
  28.                       'connected_items' => $post,
  29.                       'nopaging' => true,
  30.                       'cat'=>17,
  31.                       'connected_direction' => 'any'
  32.                     ) );
  33.                      
  34.                     // Display connected sponsors
  35.                     if ( $gold->have_posts() ) : ?>
  36.                         <?php while ( $gold->have_posts() ) : $gold->the_post(); ?>
  37.                             <?php the_title(); ?>
  38.                         <?php endwhile; ?>
  39.                        
  40.                         <?php
  41.                         // Prevent weirdness
  42.                         wp_reset_postdata();
  43.                     endif;
  44.                     ?>
  45.                    
  46.     <?php endwhile; wp_reset_postdata(); ?>
  47.     <!-- show pagination here -->
  48. <?php else : ?>
  49.     <!-- show 404 error here -->
  50.  
  51. <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement