Created
March 2, 2015 23:07
-
-
Save jamesmthornton/1536bfde93fbc82b2bfb to your computer and use it in GitHub Desktop.
Team Profile Page Template for Genesis Wordpress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This file adds the city team template to any Genesis 2.0+ Theme. | |
* | |
* @author Jim Thornton | |
* @package InboundFound | |
* @subpackage Customizations | |
*/ | |
/* | |
Template Name: Team | |
*/ | |
//* Add a custom body class to the head so we can target team pages only with css. | |
add_filter( 'body_class', 'team_add_body_class' ); | |
function team_add_body_class( $classes ) { | |
$classes[] = 'team-page'; | |
return $classes; | |
} | |
//* create a custom loop for our team template | |
add_action( 'genesis_loop', 'team_custom_loop' ); | |
function team_custom_loop() { | |
?> <section class="profiles row"> <? | |
$args = array('post_type' => 'team', | |
'orderby' => 'title', | |
'order' => 'ASC', | |
'meta_key' => 'which-office', | |
'meta_value' => 'city-name', | |
//* Use -1 posts per page in order to prevent a maximum number of team members per page | |
'posts_per_page'=>'-1'); | |
$wp_query = new WP_Query($args); | |
?> | |
<?php if($wp_query->have_posts()) : while($wp_query->have_posts()) : $wp_query->the_post(); ?> | |
<? | |
$thumb_src = null; | |
if ( has_post_thumbnail($post->ID) ) { | |
$src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'team-thumb' ); | |
$thumb_src = $src[0]; | |
} | |
?> | |
<article class="profile"> | |
<div class="profile-header"> | |
<?php if ( $thumb_src ): ?> | |
<div class="home-highlight-circle"><div class="home-highlight-circle-img"><img src="<?php echo $thumb_src; ?>" alt="<?php the_title(); ?>, <?php the_field('agent-site'); ?>" class="img-circle"> | |
<?php endif; ?> | |
</div></div></div> | |
<div class="profile-content"> | |
<h3><?php the_title(); ?></h3> | |
<p class="lead position"><?php the_field('member-title'); ?> | |
<br><a href="tel:<?php the_field('office-phone'); ?>"><i class="icon-office-phone"><?php the_field('office-phone'); ?></i></a><br> | |
<a href="tel:<?php the_field('direct-phone'); ?>"><i class="icon-direct-phone"></i><?php the_field('direct-phone'); ?></a></p> | |
<?php the_content(); ?> | |
</div> | |
<div class="profile-footer"><a href="mailto:<?php echo antispambot( get_field('team-email') ); ?>"><i class="icon-envelope"></i><?php echo antispambot( get_field('team-email') ); ?></a></div></article> | |
<?php endwhile; else: ?> | |
<p>Error: No team member data to show. Check the team php template</p> | |
<?php wp_reset_postdata(); // reset the query ?> | |
<?php endif; ?> | |
</section><? | |
} | |
genesis(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment