Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created October 15, 2011 13:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save billerickson/1289597 to your computer and use it in GitHub Desktop.
Save billerickson/1289597 to your computer and use it in GitHub Desktop.
Interstrategy Events Manager - Displaying post info
<?php
/**
* Post Info
* Displayed below the post title on the single and archive view
* @author Bill Erickson
* @link http://wordpress.org/support/topic/plugin-interstrategy-events-manager-documentation?replies=4
*
* @param string, original post info
* @return string, modified post info
*
*/
function be_post_info( $info ) {
if ( 'event' == get_post_type() && is_single() ) {
// Load the standard fields found in Event Information
global $post;
$location = esc_attr( get_post_meta( $post->ID, 'be_events_manager_location', true ) );
$start = esc_attr( date( 'F j, Y', get_post_meta( $post->ID, 'be_events_manager_start_date', true ) ) );
$end = esc_attr( date( 'F j, Y', get_post_meta( $post->ID, 'be_events_manager_end_date', true ) ) );
$cost = esc_attr( get_post_meta( $post->ID, 'be_events_manager_cost', true ) );
$telephone = esc_attr( get_post_meta( $post->ID, 'be_events_manager_telephone', true ) );
// Construct the post info only with those that aren't empty
$info = '';
if ( !empty( $location ) ) $info .= '<span class="location"><strong>Location:</strong> ' . $location . '</span><br />';
if ( !empty( $start ) && !empty( $end ) ) $info .= '<span class="date"><strong>Date:</strong> '. $start . ' to ' . $end . '</span>';
if ( !empty( $cost ) ) $info .= '<br /><span class="cost"><strong>Cost:</strong> $' . $cost . '</span>';
if ( !empty( $telephone ) ) $info .= '<br /><span class="telephone"><strong>Telephone:</strong> '. $telephone . '</span>';
} elseif ( 'event' == get_post_type() ) {
// Load all the event categories for this event
global $post;
$cats = get_the_terms( $post->ID, 'event-category' );
$categories = array();
foreach ( $cats as $cat )
$categories[] = '<a href="' . get_term_link( $cat, 'event-category') . '"> '. $cat->name . '</a>';
// Get the start date
$start = get_post_meta( $post->ID, 'be_events_manager_start_date', true );
// Construct the post info only with those that aren't empty
$info = '';
if ( !empty( $categories ) ) $info .= '<span class="categories">' . implode( ', ', $categories ) . '</span>, ';
if ( !empty( $start ) ) $info .= '<span class="start-date">Begins ' . date( 'F j, Y', $start ) . '</span>';
}
return $info;
}
add_filter( 'genesis_post_info', 'be_post_info' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment