Skip to content

Instantly share code, notes, and snippets.

@davebonds
Created May 1, 2014 02:27
Show Gist options
  • Save davebonds/c1ad5a23a83a58e70993 to your computer and use it in GitHub Desktop.
Save davebonds/c1ad5a23a83a58e70993 to your computer and use it in GitHub Desktop.
<?php
/**
* This file adds the AgentPress Listing archive template to any Agent Evolution Theme.
*
* @author Agent Evolution
* @package Move-in Ready
* @subpackage AgentPress Listings
*/
/**
* The custom post type archive template
*/
/** Force full width layout */
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
/**
* Remove the standard loop
*/
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'agentpress_listing_archive_loop' );
/**
* Custom loop for listing archive page
*/
function agentpress_listing_archive_loop() {
$count = 0;
if ( have_posts() ) : while ( have_posts() ) : the_post();
$count++;
$loop = ''; // init
$loop .= sprintf( '<a href="%s">%s</a>', get_permalink(), genesis_get_image( array( 'size' => 'properties' ) ) );
$loop .= sprintf( '<span class="listing-price">%s</span>', genesis_get_custom_field( '_listing_price' ) );
if ( '' != genesis_get_custom_field('_listing_text') ) {
$loop .= sprintf( '<span class="listing-text">%s</span>', genesis_get_custom_field( '_listing_text' ) );
}
$loop .= sprintf( '<span class="listing-address">%s</span>', genesis_get_custom_field( '_listing_address' ) );
$loop .= sprintf( '<span class="listing-city-state-zip">%s, %s %s</span>', genesis_get_custom_field( '_listing_city' ), genesis_get_custom_field( '_listing_state' ), genesis_get_custom_field('_listing_zip' ) );
$loop .= sprintf( '<a href="%s" class="more-link">%s</a>', get_permalink(), __( 'View Listing', 'agentpress' ) );
$class = $count == 1 ? 'first one-fourth' : 'one-fourth';
if ($count == 4) {
$count = 0;
}
/** wrap in post class div, and output **/
printf( '<div class="%s"><div class="widget-wrap"><div class="listing-wrap">%s</div></div></div>', join( ' ', get_post_class( $class ) ), $loop );
endwhile;
genesis_posts_nav();
endif;
}
genesis();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment