I have a twig/timber function and the code doesn't shows any error but when I go to use function in my twig template there is an error saying '' is not a function.
This is what I have in my fucntions.php file in the twig template:
add_filter( 'timber/twig', function( \Twig_Environment $twig ) {
$twig->addFunction( new Twig_Function( 'get_custom_meta', 'get_custom_meta' ) );
} );
function get_custom_meta($key,$id){
if(empty($id)){
return types_render_field($key,array("raw"=>"true","separator"=>";"));
}else{
return get_post_meta( $id, 'wpcf-'.$key, true );
}
}
and this is how I'm calling the function in the template.
{{ function(get_custom_meta('facebook', event.post_id )) }}
This in in wordpress. Thanks