1
votes

I try to import HTML into wordpress WYSIWYG custom fields and later display it correctly.

The values get written by the importer, but when I try to edit such a content type, the WYSIWYG editor is spammed with html-tags.

I tried different variants to escape the htmlspecialchars. With no succes. The WYSIWYG editor also displays those, instead of formatting the text.

Also, when i do print_custom_field in my template, the html does not get rendered, but displayed again. Obviously not what I would want.

All related content types are created with custom content type manager

https://code.google.com/p/wordpress-custom-content-type-manager/

My Question:

  • Is it a bad idea in general to import html-snippets from a (trusted) external source?

  • How can I trick the output from worpdress into rendering html for certain fields, instead of displaying it.

1
When you paste the HTML into the WYSIWYG editor, are you on the 'Visual' or "Text' tab? You should paste code into the 'Text' tab.johnnyd23
It's an importer plugin. The content does not have to be editable through wordpress. It gets automatically imported every night from a webservice. I just mentioned the Editor, because it also seems to have trouble dealing with htmlspecialchars encoded.ansi_lumen

1 Answers

2
votes

This was actually related to the view layer. Since that was not my business, I didn't care at first.

Turns out, that one has to us htmlspecialchars_decode in the templates, because the wordpress-api does htmlspecialchars on import.

The following code works fine

<? print htmlspecialchars_decode(get_custom_field('foo'));?>