Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

How to Embed SWF in Your WordPress Posts

Last updated on by
Elegant Themes
How to Embed SWF in Your WordPress Posts

If you have ever tried embedding a Shockwave Flash file into your WordPress blog then you know it can get messy. Besides, if you are hosting your blog on WordPress.com then you are not going to be able to upload flash for security reasons. If you do have your hosting account, however, then there are several ways you can go about uploading .swf files to your WordPress blog posts. The first way involves using a plugin. This way is preferred if you are not good with code. The other way requires you to know some basic html. In this article we are going to go over how to embed SWF in WordPress posts with a plugin and without a plugin.

Plugin Method

First, you need to download and install Easy Flash Embed for WordPress. This plugin is so simple that no settings are even added to your admin menu. All you have to do is used a shortcode when you are creating your posts like this:

[swf src="http://www.example.com/my-flash-file.swf" width=300 height=100]

Simply replace the src attribute with a link to your flash file and adjust height and width accordingly.

Download Easy Flash Embed plugin.

Code Method

For those of you who would like more control over your code we are now going to show you how to embed flash files directly into your WordPress posts, pages, or even themes. Although people have come up with numerous methods for doing this over the years the easiest and most standards compliant way is to use the <object> element.

The final code looks like this:

<object id="flashcontent" 
        classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
        width="550px" 
        height="400px">
  <param name="movie" value="mymovie.swf" />
 
  <!--[if !IE]>-->
  <object type="application/x-shockwave-flash" 
          data="mymovie.swf" 
          width="550px" 
          height="400px">
  <!--<![endif]-->
 
    <p>
      Fallback or 'alternate' content goes here.
      This content will only be visible if the SWF fails to load.
    </p>
 
  <!--[if !IE]>-->
  </object>
  <!--<![endif]-->
 
</object>

Note that you are using 2 <object> elements. The outer element is targeting Internet Explorer while the inner element is for all the other browsers. You can change your fallback text if necessary. You can also add extra <param> options like wmode or allowScriptAccess.

P.S. you should always use wmode=transparent, so your embed doesn’t override existing content such as a floating bar. Check out our article on how to prevent Youtube oEmbed from overriding content.


Editorial Staff at WPBeginner is a team of WordPress lovers led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »

Comments

  1. Jeff Foliage says:

    You code worked perfectly. I had been trying to get the swf movie to load and play when someone comes to the page and your code was the first to work. You might edit or put a version of the code with out the numbers so newbies know not to leave them in.

    But thank you.
    Jeff “Foliage” Folger

  2. haseeb says:

    awesome bro love it

  3. marzepani says:

    you should use
    wmode=opaque
    if you don’t need transparency.
    it’s much faster and has the same effect to “overlapping”.
    ;-)

  4. Chris says:

    It’s 2012… no one should be embedding Flash into their WordPress site, or any website for that matter!

    • Jahanzeb Khan says:

      Oh please, what if I made a flash animation and wanted to embed that? Or something just for fun. I’ll agree flash isn’t that good, but no reason to hate it that much. It’s hardly useful, but still fun.
      I find drawing everyday vectors/cartoons much easier on flash than photoshop.

    • Edouard Artus says:

      What ?! So because we’re in 2012 people shouldn’t post animations they’ve made with flash into the web for example ?

  5. Gautam Doddamani says:

    hmm i never really tried to embed flash in my posts…but never the less i will bookmark this for future use…i mostly use youtube to show off my videos..thanks for d tut!

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.