Created
February 27, 2012 12:09
-
-
Save jchristopher/1923305 to your computer and use it in GitHub Desktop.
Handlebars.js & WordPress Templates - Team Page Template
This file contains hidden or 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 | |
/* Template Name: Team */ | |
global $post; | |
// if it's an ajax request, return our JSON | |
if( isset( $_POST['ajax'] ) ) | |
{ | |
$args = array( | |
'post_type' => 'page', | |
'post_parent' => 5, | |
'posts_per_page' => 1, | |
'orderby' => 'rand' | |
); | |
// we'll try to not repeat | |
if( isset( $_POST['current'] ) ) | |
$args['post__not_in'] = array( intval( $_POST['current'] ) ); | |
$team = new WP_Query( $args ); | |
$team->the_post(); | |
$member_info = array( | |
'id' => $post->ID, | |
'name' => get_the_title(), | |
'permalink' => get_permalink(), | |
'headshot' => false | |
); | |
if( has_post_thumbnail() ) | |
{ | |
$headshot = wp_get_attachment_image_src( get_post_thumbnail_id(), 'thumbnail' ); | |
$member_info['headshot'] = $headshot[0]; | |
} | |
echo json_encode( $member_info ); | |
die(); | |
} | |
// it's not an ajax request, so render the page | |
the_post(); | |
get_header(); | |
?> | |
<div id="primary"> | |
<div id="content" role="main"> | |
<h1 class="entry-title"><?php the_title(); ?></h1> | |
<?php the_content(); ?> | |
</div> | |
</div> | |
<?php get_footer(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This gist is referenced in its parent article