Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Created February 27, 2012 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jchristopher/1923305 to your computer and use it in GitHub Desktop.
Save jchristopher/1923305 to your computer and use it in GitHub Desktop.
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
Copy link
Author

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