I have been trying to insert some code into my posts on Webmasters-central.com.

I searched the internet high and low … no use.

I installed all plugins that are out there … no use or limited use.

After two days of all sorts of manipulations, the easy and best solution I came up with is:

DISABLE VISUAL EDITOR. 95% of your problem is solved. No kidding!

I disabled the visual editor of TinyMCE and installed a plugin called ‘Dirtycode plugin’.

See the example here on how I inserted the code:

Search engine optimization – hyphens or underscores? Htaccess modrewrite rule.

STEP ONE: Disabling Visual editor.

TinyMCE has two modes – ‘Visual’ and ‘HTML’ modes. Visual editor messes up the code formatting when you switched from HTML mode. So best is to disable it. Most of the visual editor functionality is in HTML mode too like image, video insertions, all basic html tags etc.

visual editor

1. Login into your Wordpress admin panel.
2. Users > click on ‘Your profile’ link.
3. Check the the checkbox next to ‘Disable the visual editor when writing’.
4. Save it.

insert code into wordpress posts

STEP TWO: ‘Dirtycode’ plugin.

This is very simple plugin which
encloses the code in a ‘div’ tag of its own.

1. Download plugin from here – ‘Dirtycode’ plugin.
2. Upload it to your ‘wp-content/plugins’.
3. Activate it from your admin panel.

Or just go to admin panel > ‘Plugins’ > ‘Add new’ > enter ‘dirtycode’ into the textbox > click on ‘Search plugins’ button > install it from there.

How to use it?

All instruction are on the plugin page. Basically it has two modes – hiding and nonhiding method.

In hiding method, the person has to click on the link to open up the code box.

<dirtycode>YOUR CODE HERE</dirtycode>

In nonhiding method, the person can see the code box on plain site.

<dirtycode:noclick>YOUR CODE HERE</dirtycode>

I used this second method in this article post.

So right now I am happy with HTML mode of TinyMCE with this plugin.

What are you using to insert code into your wordpress posts?

Share it here!

.

Author: Radhika (c)
http://www.webmasters-central.com/




Related Posts

  • No Related Posts Found