Created
January 7, 2015 04:18
-
-
Save ronalfy/622c06a0a71a7fbc3b32 to your computer and use it in GitHub Desktop.
WordPress All in One Event Calendar - Override Avatar
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
<?php | |
//Place in mu-plugins folder | |
//Custom Twig Template Functions | |
function opubco_add_twig_functions_and_filters( $registry ) { | |
$loader = $registry->get('theme.loader'); | |
$twig = $loader->get_twig_instance(false, true); | |
$twig->addFunction( new Twig_SimpleFunction('opubco_get_event_avatar', 'opubco_get_event_avatar') ); | |
} | |
add_action( 'ai1ec_loaded', 'opubco_add_twig_functions_and_filters'); | |
//$post_id of the event | |
function opubco_get_event_avatar( $post_id, $size ) { | |
if ( has_post_thumbnail( $post_id ) ) { | |
return get_the_post_thumbnail( $post_id, $size ); | |
} else { | |
return ''; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
{{ opubco_get_event_avatar( event.post_id, 'event_thumb' ) | raw }}