We Can Do This the Easy Way or the Hard Way

We had to get some tricky code into a page on a WordPress site. Needed some fancy formatting, a bit of a column of its own with its own background color, font, etc. There were, of course, several ways to accomplish this. But in my opinion, we needed the one that would be (1) client proof and (2) future proof.

If you’re going to put HTML or PHP or any kind of code into a WordPress post or page, it risks being broken if someone edits that page in the WYSIWYG editor. The WP visual editor tends to break code as it’s trying to “help you” format the way it thinks you want things formatted. It also wants to protect you from running scripts in the editor. So open up the page, it’ll probably break things. Of course, if you open another page in the HTML or “Text” editor, you should be OK. But you’d have to remember to do that. Oh yeah, and remind anyone else with editing rights to that page to also not edit it with the Visual editor. Good luck with that. But why bother? Just make it editing-proof and everyone’s happier.

The Quick Fix or the Long-Term Strategy? What’s best for the client?

One tool I quite like to use is Hana Code Insert. It will let you go to town on your crazy code and then you can just insert a shortcode to make it run in the page. Simple. Another, albeit quite a bit more complex, method would be to design a custom page template (or post template) and run your code in the code of that template. This is even safer as the client or user can’t even break it if they tried.

We love WordPress over here at Likoma because it gives the user incredible power. But of course, with that power comes responsibility. Responsibility coupled with an understanding of how things work can be even more powerful. But when you don’t know that logging into a page with the Visual editor will break some code, then it’s not thinking about the client long term. We want things unbreakable … or at least stronger than a champagne glass.

2017-05-25T22:54:39+00:00

About the Author:

I've done the big corporate thing. I've done the creative writer thing. Now I'm happily in the middle. I like to help small businesses who are interested in "working their website before their website works them." I'm also interested in creating beautiful sites with powerful WordPress themes. Google+

Leave A Comment

CommentLuv badge

css.php

Pin It on Pinterest

Shares
Share This