Advertisement
gregrickaby

CPT Loop

Jan 27th, 2012
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.16 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * This file creates the Projects Single Page
  5.  *
  6.  * @author Greg Rickaby
  7.  * @since 1.0.0
  8.  * @required Genesis
  9.  */
  10.  
  11. /*
  12. Template Name: Project
  13. */
  14.  
  15. add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' ); // Force Full-Width Layout
  16. remove_action( 'genesis_loop', 'genesis_do_loop' ); // Remove default Genesis Loop
  17. add_action( 'genesis_loop', 'child_cpt_loop' ); // Add Custom Post Type Loop
  18. /**
  19.  * Build the custom loop to display Projects
  20.  *
  21.  * @author Greg Rickaby
  22.  * @since 1.0.0
  23.  * @required Genesis
  24.  */
  25. function child_cpt_loop() {
  26.  
  27. $loop = new WP_Query( array( 'post_type' => 'project', 'posts_per_page' => 1 ) ); ?>
  28.     <h1><?php the_title(); ?></h1>
  29.         <div id="projects">
  30.             <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
  31.                 <div id="post-<?php the_ID(); ?>" class="project">
  32.                     <p class="project-short-description"><?php echo genesis_get_custom_field( 'sfcpt_project_short_description' ); ?></p>
  33.                     <p class="project-description"><?php echo genesis_get_custom_field( 'sfcpt_project_description' ); ?></p>
  34.                 </div>
  35. <?php endwhile; ?>
  36. <?php }
  37.  
  38. /** Finish loading the page */
  39. genesis();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement