You must be logged in to post Login


Lost Your Password?

Search Forums:


 






Minimum search word length is 4 characters – Maximum search word length is 84 characters
Wildcard Usage:
*  matches any number of characters    %  matches exactly one character

How to prevent wordpress from messing up HTML?

UserPost

9:16 am
January 27, 2012


retireby40

USA

Member

posts 1381

So sometime I need to add html to my blog. For example, I want to put the Google +1 button in this page. 

http://retireby40.org/blog-rank/

I go to html view and add the code.

When I come back later to edit the page in the "visual" mode, the html would get messed up after I save.

Any tips from the wordpress experts?Wink

 

Thanks a bunch.

-Joe

retire by 40

Twitter: @retirebyforty

Facebook: Retire By 40 

9:33 am
January 27, 2012


Eric – PersonalProfitability.com

Portland, OR

Member

posts 2120

The button shows up fine for me

10:43 am
January 27, 2012


Aloysa

Member

posts 910

I see the button just fine.

Creator of:

11:35 am
January 27, 2012


Tushar @ Everything Finance

Atlanta, GA, United States

Member

posts 386

Once you add code in the HTML View, go ahead and save it first, before going to the "Visual" mode.

Tushar @ Everything Finance

 

Everything Finance

Email:    tusharm at gmail dot com
Twitter:  @AllFinance

11:47 am
January 27, 2012


retireby40

USA

Member

posts 1381

This is what I did to make it work. 

But when I come back in the future in visual mode. I will need to insert the code again. 

Is there a way to make the code stick? 

 

Tushar @ Everything Finance said:

Once you add code in the HTML View, go ahead and save it first, before going to the "Visual" mode.

retire by 40

Twitter: @retirebyforty

Facebook: Retire By 40 

12:06 pm
January 27, 2012


Dividend Ninja

Vancouver B.C.

Member

posts 198

Hi Joe (I'm not retired by 40),

There's two problems here, and its better to put a Google Plus One button directly into your template, or better yet use a plugin! It won't work, and here's why:

(1) Google uses its own markup language much like facebook does. It is primarily AJAX and JQuery based. Therefore when you pasted the code into an html editor (wordpress uses TinyMCE), the basic html editor doesn't know how to interpret it. It does the best it can, but it won't save the code, cause it doesn't know what to do with it.

(2) Until the latest release WordPress simply didn't save any html once you switched from html to page view. This was very annoying. Even now its not perfect – but it will do basic html.

SO the answer to your question is, don't bother – put Google Plus One into your template. Better yet use a plugin so you don't mess up the template!!! <– re-read that part. Havign said that Google Plus One is tricky to style and work with, hence I like a plugin for this one.

Hope that helps. Cheers!

The Dividend Ninja
http://www.dividendninja.com

t  f  @

12:51 pm
January 27, 2012


retireby40

USA

Member

posts 1381

Hi Dividend Ninja!

I see. I use a plugin for my regular posts, but for this page I want to +1 my main page. That's why I put it there. 

Will it really mess up my template???

 

I saw this problem last year when I tried to add amazon affiliate codes to the html. 

Thanks

retire by 40

Twitter: @retirebyforty

Facebook: Retire By 40 

3:42 pm
January 27, 2012


Suba @ Wealth Informatics

Moderator

posts 1876

Joe, this is a known problem with wordpress. With thesis you can easily add it to the custom functions instead of adding it to individual page. It happens especially when you are adding <scripts></scripts>. I think the Advanced TinyMCE plugin fixes this problem, but I don't like installing a plugin for occasional use. The best bet to is to add it to the custom functions. I have never tries the amazon widgets though, I just use the text link like any regular url.

Visit me @ Wealth Informatics Financial freedom through information

Connect with me via Facebook Wealth Informatics page

Follow me with Twitter

Have a comment or want to say hello – wealth [dot] Informatics [at] gmail [dot] com

Editor @ Broke Professionals

6:42 pm
January 27, 2012


Glen Craig

Member

posts 1087

I keep a text file handy with code I need to re-add in these situations.  I have one page where this happens often with a piece of code.

8:55 pm
January 27, 2012


Dividend Ninja

Vancouver B.C.

Member

posts 198

retireby40 said:

Hi Dividend Ninja!

I see. I use a plugin for my regular posts, but for this page I want to +1 my main page. That's why I put it there. 

Will it really mess up my template???

 

I saw this problem last year when I tried to add amazon affiliate codes to the html. 

Thanks

Hi retireby40, yes in this case you would want to put the code into the template since its a one time deal. Wrap the code in a div tag so you can modify and style it accordingly, i.e.

<div id="p-one-button">

 THE CODE

</div>

The Dividend Ninja
http://www.dividendninja.com

t  f  @


About the Yakezie.com Forum

Forum Timezone: America/Los_Angeles

Forum Stats:

Groups: 2
Forums: 9
Topics: 6383
Posts: 84794

Membership:

There are 13651 Members
There have been 20 Guests

There are 9 Admins
There are 8 Moderators

Top Posters:

My Personal Finance Journey – 3159
Khaleef @ KNS Financial – 3149
Budgeting in the Fun Stuff – 3048
Sustainable PF – 2759
Miss T @ Prairie Eco-Thrifter – 2213
Eric – PersonalProfitability.com – 2120

Administrators: The College Investor (1935 Posts), Financial Samurai (1803 Posts), LaTisha @YoungFinances (1715 Posts), Forest Parks (1337 Posts), 20s Finances (1147 Posts), Money Reasons (697 Posts), Chris Johnson (78 Posts), Sydney at Untemplater (0 Posts), Suba (0 Posts)

Moderators: Suba @ Wealth Informatics (1876 Posts), sooverthis (1041 Posts), PK @ DQYDJ (361 Posts), jmichelsen (208 Posts), Ramona (13 Posts), JeremyNJohnson (4 Posts), Moderator (0 Posts), rackgeek (0 Posts)