Created
August 19, 2018 03:41
-
-
Save rgadon107/cc2f1a2a66ba1e0992bb985e4c6a55c6 to your computer and use it in GitHub Desktop.
Render an event venue when calling 'single-event.php'.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'genesis_entry_header', __NAMESPACE__ . '\add_content_wrap_markup_open', 3 ); | |
/* | |
* Add content wrap around Event entry_header & render post thumbnail on single. | |
* | |
* @since 1.0.0 | |
* | |
* return void | |
*/ | |
function add_content_wrap_markup_open() { | |
$event_id = (int) get_the_ID(); | |
printf( '<div %s>', genesis_attr( 'before-entry-header-wrap' ) ); | |
echo add_venue_image_to_single_event(); | |
} | |
/* | |
* Add an event venue image to the single-event template. | |
* | |
* @since 1.0.0 | |
* | |
* @return void | |
*/ | |
function add_venue_image_to_single_event() { | |
if ( is_post_type_archive( 'events' ) ) { | |
return ''; | |
} | |
return render_event_venue_image( $event_id ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@hellofromtonya: Given that I only plan to get the image for the single-events template, then it makes sense to use the conditional in the function
add_content_wrap_markup_open()
and call the functionrender_event_venue_image( $event_id )
.Your point about about reusing the 'get_image' function for other use cases in a project is a good one. In that situation, it would make sense then to build the 'get_image()' function in a more generic way to use as a helper function or method throughout the project.