Default template

Custom code on Wordpress

By naitian.

Last edited by pdhyani. Created .

Table of Contents:

There are a couple of options when it comes to inserting custom HTML/CSS/Javascript in an article or on a page. The first, and best supported, method is to use iframe embeds. However, if you need greater access to the rest of the article, an alternative option is to use the custom HTML block available through the Wordpress editor.

IFrames

IFrame embeds are supported in the Wordpress editor. Further, pym-enabled embeds are supported through the pym.js block. The data team uses iframes to embed interactive data graphics into stories. Note that since pym requires js to run, you must disable AMP when using a pym block.

HTML Block

If IFrames are insufficient, custom HTML, Javascript and CSS can be directly embedded into the article using custom HTML blocks. That said, this solution should be used sparingly and with caution, as the code is less maintainable and there is less separation between custom code and the website.

In progress: the web team is working on a better workflow for developing these “raw” embedded pages.