Simple Code Embed


Embed code, whether HTML or JavaScript, directly in your posts and pages. Ideal for showing YouTube videos!

Download

Download Simple Code Embed (v1.1, 19/06/2009)

Change Log

Version 1.0

  • Initial release

Version 1.1

  • The instructions have been corrected (thanks to John J. Camilleri for pointing it out!)
  • Plugin has been tested with version 2.8 of WordPress.
  • No code changes have been made

Installation

  1. Upload the entire simple-code-embed folder to your wp-content/plugins/ directory.
  2. Activate the plugin through the ‘Plugins’ menu in WordPress.
  3. There is no options screen.

Configuration

As you probably know if you put code directly into your post or page, it is often simply displayed as written rather than actually actioned. So, if you put the embed code of a YouTube video in a post it won’t display the video.

This plugin makes use of the Custom Fields facility when creating/editing posts and pages.

Add a custom field named CODEx, where x is a number between 1 and 5 (this allows you to have up to 5 pieces of embedded code per page or post). In the value field place your embedded code – this can be HTML, XHTML, JavaScript, etc. Server side languages, such as PHP, doesn’t work.

Now, in your post or page simply add a reference to %CODEx% (again where x is the number that you used before).

Here’s an example. I create a custom field named CODEx, where x is between 1 and 5, with a value of…

<object width="425" height="344">
<param name="movie" value="http://www.youtube.com/v/oHg5SJYRHA0&hl=en&fs=1">
</param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/oHg5SJYRHA0&hl=en&fs=1"
type="application/x-shockwave-flash" allowscriptaccess="always"
allowfullscreen="true" width="425" height="344"></embed>
</object>

Then, where I wish the video to appear in my post I simply add %CODEx% (replacing x with the appropriate number between 1 and 5). Simple!

Problems/Queries

Please report any problems, or suggestions for enhancements, to me either via my contact form or by commenting on the appropriate entries on my blog.

Updates

Updates to this and any other of my WordPress plugins will be published on this blog.

Subscribe to my WordPress category feed.


Share with Delicious Share with Digg Share with Facebook Share with LinkedIn Share with MySpace Share with reddit Share with StumbleUpon Share with Twitter

Comments

  1. Federico

    Don’t work for me, I use WP 2.7.1, and put %CODEx% in the visual editor and nothing, try using HTML editor and nothing… :(

  2. David

    Strange. I assume you’ve placed the code in a custom field which you’ve named CODE1? In which case, it should work. This recent blog entry of my own uses the plugin… http://www.artiss.co.uk/2009/05/you-had-it-wrong-all-along

  3. Federico

    Yes, I named it CODE1 with the “%” after and before, and nothing, then, when I see your reply without the %, I try again without them… but nothing, I see “CODE1″ in my entry, instead the iframe :(

  4. Anita

    I’ve got the same problem – the page is just blank.

    :-(

  5. David

    Ok, the issue has now been fixed – the code was working fine, it was my instructions that were wrong. I’ve now correct them, both above and in the README file that accompanies the plugin.

    In a nutshell, you should NOT put percentage signs around your custom field name – only when you specify it in your actual post should you do this.

  6. Anita

    Works like a dream. Fantastic!

    Thank you,
    Anita

  7. Sean

    Is there a way to allow this to work with embedding code in the sidebar?

    Thanks in advance,
    Sean

  8. David

    Any code can be embedded in the sidebar by adding it into the appropriate theme file – usually sidebar.php. Because a blog post or page is dynamically generated from databases, this is why they need a special plugin to add such a facility.

  9. Bradley Brown

    Thank you for this David. I was able to install the plug-in right from the built-in Wordpress MU Plug-in system and activate it system-wide. I’ve tested it and posted the instructions for our users.

  10. Joe Siegler

    This works on WP 2.91.

  11. Diego

    i´m using 2.91 and atahualpa. i´m trying to embed my blip tv player, but i get nothing… i´ve followed the instructions, so what do you think could be wrong?

    regards

  12. David

    Send me the code and I’ll try it!

Pingbacks & Trackbacks

Leave a Comment

All these comments are validated before being placed on the site. I will NOT allow any spam to be shown, I do not follow the links myself and obvious self-promotion of your site is not accepted either.

CAPTCHA Image CAPTCHA Audio
Refresh Image