this one works for me, but how can i put in there a custom field?
<?php echo apply_filters( 'the_content', '[flv]location[/flv]' ); ?>
http://codex.wordpress.org/Custom_Fields
http://codex.wordpress.org/Function_Reference/get_post_meta
Put the URL in the custom field.
<?php
$videourl = get_post_meta( $post->ID, 'some_key', true );
if ( $videourl )
echo apply_filters( 'the_content', "[flv]$videourl[/flv]" );
?>
Hi,
In my theme, i have a custom template file where i want to show youtube and daily motion video by the video URL. I have only raw URL nothing else.
Why can’t I get this code to work in my theme? Here is my code,
<div id=”video”>
<div id=”video-inside”>
<?php $videourl = get_post_meta( $post->ID, ‘video’, true ); if ( $videourl )echo apply_filters( ‘the_content’, “[flv]$videourl[/flv]” ); ?>
</div>
</div>
But when I load the page if loads blank. Does this no longer work?
Replace the ” ” around [flv]$videourl[/flv] with ‘ ‘
I am almost there – the video shows up in the right place but the URL isn’t quite right…
code used (as above but with vimeo tags instead):
<?php
$videourl = get_post_meta( $post->ID, 'video', true );
if ( $videourl )
echo apply_filters( 'the_content', '[vimeo]$videourl[/vimeo]' );
?>
results on page:
<span class="vvqbox vvqvimeo" style="width:635px;height:300px;"><iframe id="vvq-103-vimeo-1" src="http://player.vimeo.com/video/$videourl?title=1&byline=1&portrait=0&fullscreen=1" width="635" height="300" frameborder="0"><a href="http://www.vimeo.com/$videourl">http://www.vimeo.com/$videourl</a></iframe></span>
it seems to be the $videourl bit that is going wrong, but i’m afraid i don’t know enough about PHP to figure out why!
WP version: 3.2.1
example page: http://www.braincubecorp.co.uk/eatme/media/video/this-is-the-title-of-a-video-post/
video link: http://vimeo.com/30391279
Hiya
The $videourl variable is being passed as a string.
Try this:
<?php
$videourl = get_post_meta( $post->ID, ‘video’, true );
if ( $videourl )
echo apply_filters( ‘the_content’, ‘[vimeo]’ . $videourl . ‘[/vimeo]’ );
?>
xave, you are a star! works perfectly, thank you.