I'm trying to get a video to display inside a widget which is called from a custom field inside a post. The code I am using is here:
<?php query_posts('cat=8&showposts=1'.get_option('posts_per_page')); ?> <?php if(have_posts()) : while(have_posts()) : the_post(); ?><?php if( get_post_meta($post->ID, "youtube", true) ): ?> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="The W Club: <?php the_title(); ?>"><?php the_title(); ?></a></h2> <iframe width="250" height="199" src="http://www.youtube.com/embed/<?php echo get_post_meta($post->ID, "youtube", true); ?>?rel=0" frameborder="0" allowfullscreen></iframe> <?php else: ?> Video can not be displayed. <?php endif; ?> <?php endwhile; endif; ?> <?php echo get_post_meta($post->ID, "youtube", true); ?>
I have created a post inside category 8 (videos), entered a title, added the custom field (youtube) with the right code for the URL to display the video.
When I load the page all the widget displays is "Video can not be displayed", it doesn't use the post title and I can't get it to even echo the custom field entry.
Any ideas as to what is going on? The custom php widget I am using is http://wordpress.org/extend/plugins/php-code-widget/
Thanks in advance.
Of course if anyone has a better way of doing what I'm trying to achieve that would be awesome too :)