I wrote a very quick and simple mark-up that works -- I know WordPress has a built in oEmbed system, this doesn't follow it - at all. However, I'd be a fool not to share it if you can adapt a solution that works for me at least.
Sampled Code Notes: For this project I had to create a custom post type for videos
so that my client could easily go in and add video posts with the Video ID from YouTube. These videos were of Houses their company had listed, and then professionally had videos shot. Their current workflow worked, and the rate of developing a video was about 5-6 weeks per, and maybe 13-15 videos per year.
When I had to start this project it was my understanding then that the oEmbed wasn't really needed for my uses, I may now in retrospect regret the decision on the argument of syntax, elegance, etc -- albeit, it's been rigid enough for this long without fail.
With that said, I also used a Custom Metabox Class to use get_post_meta
for the ID of the video, I didn't ever build in Validation or Sanitizing of the input in the case that a video wasn't entered with the expectation of someone posting to a custom post type of videos
that they would in fact not skip this very simple step. I'm a little over-confident at times, therefore you might want to add in some of that stuff per your needs
Getting Started: Create a `page-your-custom-post-type.php and put in the following:
<?php
/*
Template Name: Your Template Name
*/
get_header();
function customBlogFeed() {
// The Query
$the_query = new WP_Query( array ( 'post_type' => 'your-custom-post-type', 'posts_per_page' => '6' ) );
It is important that 'post_type' => 'your-custom-post-type'
is linked to your page-your-custom-post-type.php page, otherwise it won't know what to output. Additionally, you can add more parameters to the WP_Query array()
WP_Query WordPress Codex Page.
// The Loop
while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<div class="port">
<h2 class="smaller">
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
<?php the_title(); ?>
</a>
<span style="font-size: 11px;">
Posted on: <?php the_time(get_option('date_format')); ?> by: <?php echo get_the_author(); ?>
</span>
</h2>
Linking to your custom post type by default WordPress will feed this through single.php if it exists and fallback to index.php if single.php doesn't exist. However, If you create a single-your-custom-post-type.php WordPress will use that as your page-template
for your custom post type.
<object width="288" height="176">
<param name="movie" value="http://www.youtube.com/v/<?php $meta = get_post_meta(get_the_ID(), 'sb_metabox_video_url', true); if (strlen($meta) > 1 ) { echo $meta; } ?>?version=3&rel=0&modestbranding=1&autoplay=0&controls=0"></param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/<?php $meta = get_post_meta(get_the_ID(), 'sb_metabox_video_url', true); if (strlen($meta) > 1 ) { echo $meta; } ?>?version=3&rel=0&modestbranding=1&autoplay=0&controls=0" type="application/x-shockwave-flash" width="288" height="176" allowscriptaccess="always" allowfullscreen="true"></embed>
</object>
oEmbed: I'm also passing these parameters to YouTube:
?version=3&rel=0&modestbranding=1&autoplay=0&controls=0
Which tell it how to style the Video Player it renders.
<?php the_excerpt(); ?>
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Continue reading %s', 'twentyten' )); ?>" rel="bookmark"><img src="<?php bloginfo('template_directory') ?>/images/button_more.gif" alt="<?php printf( esc_attr__( 'Continue reading %s', 'twentyten' )); ?>" border="0" class="none" style="height: 28px!important; width:55px!important;" /></a>
</div>
<?php endwhile;
// Reset Post Data
wp_reset_postdata();
}
?>
Closing it all up with your wp_reset_postdata();
and you've got a page that will use WP_Query
to loop through 6 Posts with the_title()
the_excerpt
and an oEmbed Video.
Cheers!