Skip to content

Instantly share code, notes, and snippets.

@curtismchale
Created August 31, 2011 05:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save curtismchale/1182856 to your computer and use it in GitHub Desktop.
Save curtismchale/1182856 to your computer and use it in GitHub Desktop.
Populates GF dropdown
/*
* Load any taxonomy terms
*/
function load_cpt_choices($post_type, $type, $first_choice = '', $term) {
$choices = array();
if ($type === 'select') {
$posts = get_posts('post_type='.$post_type.'&numberposts=-1&school_type='.$term);
}
if( $post_type == 'school' ){
foreach($posts as $post) {
$hsZip = get_post_meta( $post->ID, 'sfn_tan_hs_zip', true);
$hsState = get_post_meta( $post->ID, 'sfn_tan_hs_state', true);
$hsName = $post->post_title;
$hsString = $hsZip . ', '. $hsName . ', ' . $hsState;
$choices[] = array('value' => $post->ID, 'text' => $hsString);
}
} else {
foreach( $posts as $post ){
$choices[] = array( 'value' => $post->ID, 'text' => $post->post_title );
}
}
return $choices;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment