Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Handlebars.js & WordPress Templates - Team Page Template
<?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(); ?>
@jchristopher

This comment has been minimized.

Copy link
Owner Author

@jchristopher jchristopher commented Feb 27, 2012

This gist is referenced in its parent article

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment