Friday, July 18, 2014

Embed SWF file in your WordPress Theme

Flash files can give extra uniqueness of your WordPress site. But it’s not easy to embed a flash (.swf) file to WordPress, because you won’t be able to upload flash for security reasons.

There are many methods. You can use a plugin to complete this task. You can also do it by placing some codes into your theme template if you want to show it directly/by default on theme. I’m going to describe the last method step by step.

Step – 1: At first, create a folder named “swf” into your root directory. Upload your flash file into the newly created folder.
Step – 2: If you want to show the file on the top of every page, open the header.php file. Find out the place where you want to show it. Then put these codes in the exact place of the header.php file.

                    <div class="flash">
<object width="960" height="250">
                                                            <param name="movie" value="<?php echo get_template_directory_uri(); ?>/swf/your-file-name.swf"></param>
                                                            <param name="quality" value="high"></param>
                                                            <param name="wmode" value="window"></param>
                                                            <param name="menu" value="false"></param>
                                                            <param name="bgcolor" value="#FFFFFF"></param>
                                                            <param name="flashvars" value=""></param>
                                                            <embed type="application/x-shockwave-flash" width="960" height="250" src="<?php echo get_template_directory_uri(); ?>/swf/your-file-name.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" flashvars="" ></embed>
                                                            </object>
                                                            </div>

Step – 3: Find out “your-file-name.swf” and replace it with the file name you uploaded into your swf folder.
Step – 4: Now visit your site and check if it is working. It works for me, hope will also work for you.
Step – 5: If you want to stylize the flash file section from css, you can do it using a class “flash”.

That’s all. Try it yourself and run your own flash file. 

0 comments:

Post a Comment