Can you make Viper’s Video Quicktags to work with a custom field too ?
-
Is there a way to enable this plugin for custom fields ?
Let’s say I’m paste this code in custom field named embed
[youtube]https://www.youtube.com/watch?v=k8fLRPETv_0[/youtube]
————————————
then I’m showing like this
<?php query_posts(‘tag=video&showposts=1’); ?>
<?php while (have_posts()) : the_post(); ?>
<?php woo_get_custom(’embed’); ?>
<?php endwhile; ?>————————————
And the function woo_get_custom is here:
// Get Custom Embed
function woo_get_custom($key, $width=0, $height=0) {global $post;
$custom_field = get_post_meta($post->ID, $key, true);if ($custom_field) {
if ($width == 0) :
// Get custom width and height
$width = get_post_meta($post->ID, ‘width’, true);
$height = get_post_meta($post->ID, ‘height’, true);
endif;// Set values
if ( !$width ) $width = ‘width=”313″‘; else $width = ‘width=”‘.$width.'”‘;
if ( !$height ) $height = ‘height=”250″‘; else $height = ‘height=”‘.$height.'”‘;$custom_field = preg_replace( ‘/width=”[^”]+”/’ , $width , $custom_field );
$custom_field = preg_replace( ‘/height=”[^”]+”/’ , $height , $custom_field );
?>
<div class=”video”>
<?php echo $custom_field; ?>
</div>
<?php
}
else { //else, return
return;
}
}Thank you very much, great job ??
- The topic ‘Can you make Viper’s Video Quicktags to work with a custom field too ?’ is closed to new replies.