1. Documentation
  2. WooFramework Codex


Introduction ↑ Back to top

Placing embed code in your posts can be unpredictable and frustrating. With the woo_embed function you can define where in your post you want your video to appear and set the width and height parameters on the fly, so that there is not need to adjust it at a later stage in your WordPress sites life time.

What is woo_embed()? ↑ Back to top

With the use of custom fields, “embed” to be specific, you can add a video embed code to your post. This comes in handy when you have a category, or tag, specifically assigned for your collection of video posts, giving WooThemes the ability to add interesting custom widgets into your sidebar that focus on your video posts.

The main advantage of embed code being stored in the custom fields is that they can be re-sized to specific dimensions, giving you much more flexibility when moving or customizing your theme.

Most themes come with a embed field in the post/page custom settings panel. But more can be added following the Adding Post/Page Options in the WooCodex or using the built-in custom field functionality in WordPress.

Parameters ↑ Back to top

  • key – The name of the custom field holding the video embed code. Default is embed
  • width – Set the width of the embed output.
  • height – Set the height of the embed output.
  • class – Add a custom class to the div wrapping the embed code output. Default is video
  • id – Assign a specific post id to get the embed code from.

Examples ↑ Back to top

Please note that woo_embed returns the output so it needs to be echoed out, unlike woo_image.

Basic Usage ↑ Back to top

<?php if (have_posts()) : ?>  
<?php while (have_posts()) : the_post(); ?>  
<div class="post">  
	<?php echo woo_embed('key=embed&width=420&height=300'); ?> 

    <?div class="entry"><??php the_excerpt(); ?><?/div>  
<?php endwhile; else: ?> 
<div class="post">  
	<p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>

From Post ID ↑ Back to top

<?php echo woo_embed('id=44&key=embed&width=420&height=300'); ?> 
<?php echo woo_embed('id=44&key=embed_secondary&width=420&height=300'); ?>

WooCommerce - the most customizable eCommerce platform for building your online business.

  • 30 day money back guarantee
  • Support teams across the world
  • Safe & Secure online payment