Amazon code without a plugin

Just paste the code into the HTML editor. It’s advisable to not use the Visual editor if the post is edited after saving. A plugin is not necessary, just convenient. For example, at left is a text+image iframe link. It has not been modified except to ensure that no line breaks are in the code and to change ampersands to & for XHTML compliance. The irony is that iframes are disallowed in XHTML strict, so the post will fail validation anyway.

Here is a simple link for Science Fiction and Fantasy books also pasted into the HTML editor.

Although not required, I prefer the convenience of using the TinyMCE Valid Elements plugin and the RawHTML plugin to protect my code.

The TinyMCE Valid Elements plugin configures the Visual Editor to allow specified HTML tags, such as iframes and scripts. You enter the tags using a simple form with text boxes for the tags and attributes. For example, you could type "iframe" into the tag text box, and then add the iframe attributes that should be preserved (src, style, width, height, scrolling, frameborder).

The RawHTML plugin is easy to use and effective. You simply add special "raw" comment tags around HTML that WordPress should leave alone. RawHTML also adds 4 convenient options to the HTML editor that affect the entire post:

  1. Disable wptexturize (disable automatic curly quotes and typograpical marks)
  2. Disable automatic paragraphs (no worries about line breaks adding code-breaking <p> tags)
  3. Disable convert_chars (prevent problems with conversion of ampersands, brackets, and some unicode characters)
  4. Disable smilies

I’ve refrained from using any of those options in this post. It was really hard!

At right is an Amazon "Widget Source" search widget that contains a JavaScript with line breaks. It’s a good habit to enclose lines of JavaScript in commented <![CDATA[ ... ]]> tags for XHTML compliance. The search widget code was preserved intact, except that the angle bracket closing the <![CDATA[ tag was converted to &gt;. If you view source, you’ll see that WordPress automatically added paragraph tags around the text+image iframe link.

Using the rawHTML plugin with the options to disable auto-paragraphs and convert-chars would have prevented the extra <p> tag and the mangled angle bracket. It’s possible to disable auto-paragraphs altogether, if you trust yourself to always include them where necessary. Except for this post, I would use the rawHTML plugin when adding code or when I want the formatting "just so."

To add Amazon links or widgets to a sidebar, open the Widgets panel in the Dashboard and drag a Text widget into the sidebar and paste the code. A title is optional. No plugin is needed when using the Widgets panel.

Share

Leave a Reply

  

  

  


*

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>