Skip to content

Instantly share code, notes, and snippets.

@benbalter
Created January 15, 2012 16:03
Show Gist options
  • Save benbalter/1616264 to your computer and use it in GitHub Desktop.
Save benbalter/1616264 to your computer and use it in GitHub Desktop.
Display Custom Fields
function content_filter( $content ) {
global $post;
$output = array();
$taxs = get_taxonomies( array( 'object_type' => array( $post->post_type ) ) );
foreach ( $taxs as $tax ) {
$tax = get_taxonomy( $tax );
$terms = get_the_term_list( $post->ID, $tax->name, null, ', ' );
$output[ $tax->labels->singular_name] = $terms;
}
$postmeta = get_post_custom( $post->ID );
foreach ( $postmeta as $key => $value ) {
$key = apply_filters( 'cdbs_postmeta_key', $key, $value );
$output[ $key ] = $value[0];
}
ksort( $output );
$content .= '<div class="postmeta">';
foreach ( $output as $label => $value ) {
$content .= '<div class="postmeta-row">';
$content .= '<div class="postmeta-label">' . $label . ':</div>';
$content .= '<div class="postmeta-value">' . $value . '</div>';
$content .= '</div>';
}
$content .= '<div class="postmeta-row">&nbsp;</div></div>';
return $content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment