Skip to content

Instantly share code, notes, and snippets.

@srikat
Last active Apr 12, 2016
Embed
What would you like to do?
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