Skip to content

Instantly share code, notes, and snippets.

@csbeck
Created June 24, 2013 22:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csbeck/5854118 to your computer and use it in GitHub Desktop.
Save csbeck/5854118 to your computer and use it in GitHub Desktop.
Custom Archive Listing Page #01
<?php
/**
* Template Name: Professionals Listing Page
* Description: Used as a page template to show page contents, followed by a loop through a CPT archive
*/
remove_action ('genesis_loop', 'genesis_do_loop'); // Remove the standard loop
add_action( 'genesis_loop', 'custom_do_loop' ); // Add custom loop
function custom_do_loop() {
// Intro Text (from page content)
echo '<div class="page hentry entry">';
echo '<h1 class="entry-title">'. get_the_title() .'</h1>';
echo '<div class="entry-content">';
$page_object = get_page( get_the_id() );
echo $page_object->post_content;
$args = array(
'in_category' => 'professionals', // enter your custom post type
'orderby' => 'pro_name_sort',
'order' => 'ASC',
'posts_per_page'=> '6', // overrides posts per page in theme settings
);
$loop = new WP_Query( $args );
if( $loop->have_posts() ):
while( $loop->have_posts() ): $loop->the_post(); global $post;
echo '<div id="professionals">';
echo '<div class="professional-item">';
echo '<div class="testimonial-image"><a href="' . get_permalink() . '">'. get_the_post_thumbnail( $id, array(75,112) ).'</a></div>';
echo '<p class="pro-name"><a href="' . get_permalink() . '">' . get_the_title() . '</a></p>'; //retrieve employee name
echo '<p class="pro-title">' . genesis_get_custom_field( 'pro_title' ) . '</p>'; //retrieve employee title
echo '<p class="pro-phone-number">' . genesis_get_custom_field( 'pro_phone_number' ) . '</p>'; //retrieve employee phone number
echo '<p class="pro-email-address"><a href="mailto:' . genesis_get_custom_field( 'pro_email_address' ) . '">' . genesis_get_custom_field( 'pro_email_address' ) . '</a></p>'; //retrieve employee email
echo '</div>'; //end professional-item
echo '</div>'; //end professionals
endwhile;
endif;
// Outro Text (hard coded)
echo '</div><!-- end .entry-content -->';
echo '</div><!-- end .page .hentry .entry -->';
}
/** Remove Post Info */
remove_action('genesis_before_post_content','genesis_post_info');
remove_action('genesis_after_post_content','genesis_post_meta');
genesis();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment