dragunoff

wpquestions.com, ID = 2851

Aug 17th, 2011
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.02 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Template Name: Trustees' Posts
  4.  */
  5. ?>
  6.  
  7. <?php get_header(); ?>
  8.  
  9. <h2>Directors - USA</h2>
  10.  
  11. <?php // separate loop
  12.     $directors_usa = new WP_Query();
  13.     $directors_usa->query( array(
  14.         'posts_per_page' => 4, // number of posts to retrieve
  15.         'post_type' => 'directors', // custom post type slug
  16.         'tax_query' => array(
  17.             array(
  18.                 'taxonomy' => 'location', // taxonomy
  19.                 'field' => 'slug', // term field to match agains
  20.                 'terms' => 'usa' // actual term
  21.                 )
  22.             )
  23.         )
  24.     );
  25.    
  26.     // loop
  27.     if ($directors_usa->have_posts()) : ?>
  28.    
  29.         <?php while ($directors_usa->have_posts()) : $directors_usa->the_post(); ?>
  30.            
  31.             <div <?php post_class(); ?>>
  32.            
  33.                 <?php // post thumbnail
  34.                 if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
  35.                     the_post_thumbnail();
  36.                 } ?>
  37.                
  38.                 <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><br />
  39.                
  40.                 <?php echo get_the_term_list( $post->ID, 'position', 'Position: ', ' ', '' ); ?>
  41.                
  42.             </div>
  43.            
  44.         <?php endwhile; ?>
  45.        
  46.     <?php endif; ?>
  47.    
  48.  
  49. <h2>Directors - Europe</h2>
  50.  
  51. <?php // separate loop
  52.     $directors_europe = new WP_Query();
  53.     $directors_europe->query( array(
  54.         'posts_per_page' => 4, // number of posts to retrieve
  55.         'post_type' => 'directors', // custom post type slug
  56.         'tax_query' => array(
  57.             array(
  58.                 'taxonomy' => 'location', // taxonomy
  59.                 'field' => 'slug', // term field to match agains
  60.                 'terms' => 'europe' // actual term
  61.                 )
  62.             )
  63.     );
  64.    
  65.     if ($directors_europe->have_posts()) : ?>
  66.    
  67.         <?php while ($directors_europe->have_posts()) : $directors_europe->the_post(); ?>
  68.            
  69.             <div <?php post_class(); ?>>
  70.            
  71.                 <?php // post thumbnail
  72.                 if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
  73.                     the_post_thumbnail();
  74.                 } ?>
  75.                
  76.                 <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><br />
  77.                
  78.                 <?php echo get_the_term_list( $post->ID, 'position', 'Position: ', ' ', '' ); ?>
  79.                
  80.             </div>
  81.            
  82.         <?php endwhile; ?>
  83.        
  84.     <?php endif; ?>
  85.  
  86.  
  87.  
  88. <h2>Staff</h2>
  89.  
  90. <?php // separate loop
  91.     $staff = new WP_Query();
  92.     $staff->query( array(
  93.         'posts_per_page' => 4, // number of posts to retrieve
  94.         'post_type' => 'staff', // custom post type slug
  95.         'tax_query' => array(
  96.             array(
  97.                 'taxonomy' => 'trustee', // taxonomy
  98.                 'field' => 'slug', // term field to match agains
  99.                 'terms' => 'yes' // actual term
  100.                 )
  101.             )
  102.     );
  103.    
  104.     if ($staff->have_posts()) : ?>
  105.    
  106.         <?php while ($staff->have_posts()) : $staff->the_post(); ?>
  107.            
  108.             <div <?php post_class(); ?>>
  109.            
  110.                 <?php // post thumbnail
  111.                 if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
  112.                     the_post_thumbnail();
  113.                 } ?>
  114.                
  115.                 <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><br />
  116.                
  117.                 <?php echo get_the_term_list( $post->ID, 'position', 'Position: ', ' ', '' ); ?>
  118.                
  119.             </div>
  120.            
  121.         <?php endwhile; ?>
  122.        
  123.     <?php endif; ?>
  124.  
  125.  
  126. <?php get_sidebar(); ?>
  127.  
  128. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment