Skip to content

Instantly share code, notes, and snippets.

@srikat
Last active April 12, 2016 23:34
Show Gist options
  • Save srikat/6730a60fbeeeba82eda528270933f069 to your computer and use it in GitHub Desktop.
Save srikat/6730a60fbeeeba82eda528270933f069 to your computer and use it in GitHub Desktop.
How to display custom fields above other widgets of sidebar in Genesis. https://sridharkatakam.com/display-custom-fields-widgets-sidebar-genesis/
// Display values of custom fields at the top of Primary Sidebar on event CPT singular pages
add_action( 'genesis_before_sidebar_widget_area', 'sk_single_event_custom_fields' );
function sk_single_event_custom_fields() {
// if we are not on a single event page, abort.
if ( !is_singular( 'event' ) ) {
return;
}
$event_cost = get_post_meta( get_the_ID(), 'event_cost', true );
$event_sign_up_url = get_post_meta( get_the_ID(), 'event_sign_up_url', true );
if ( $event_cost || $event_sign_up_url ) {
echo '<section class="widget event-custom-fields"><div class="widget-wrap">';
if ( $event_cost ) {
echo '<p>Event Cost: $', $event_cost, '</p>';
}
if ( $event_sign_up_url ) {
echo '<p><a href="', $event_sign_up_url , '" class="button">Sign Up</a></p>';
}
echo '</div></section>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment