Embed youtube from custom field value
-
is there any way to embed youtube video by getting link ftom custom field?
i use the code bellow, but it’s not works ??
add_action (‘__after_content_title’, ‘display_custom_fields_block2′);
function display_custom_fields_block2() {
if ( ! is_singular()) return;
$custom_fields2_array = array(
‘youtube’ => ‘Watch Film’,
);
$output2 = custom_fields2_iteration($custom_fields2_array);
if (strlen($output2) > 0 )
echo ‘
‘.
$output2.’
‘;
}
function custom_fields2_iteration ($custom_fields2_array) {
$output2 = ”;
foreach ($custom_fields2_array as $custom_field2 => $label) :
$custom_field2_value = get_post_meta(get_the_ID(), $custom_field2, true);
$output2 .= (strlen($custom_field2_value) > 0 ? ‘‘.$label.’: [embed width="640" height="360"]‘.$custom_field2_value.’[/embed]
‘ : ”);endforeach;
return $output2;
}
- The topic ‘Embed youtube from custom field value’ is closed to new replies.