0

I looking to find a Wordpress Addon that would allow me to embed HTML files directly in the my WordPress interface.

After having done some research the only method I seem to find is by adding the HTML files within our Wordpress theme / website by putting them in their own directory, but this is not what I want.

Another option I found is to use iframes but this might not be the best the approach.

Does anyone know of any options as to how to embed HTML files directly in the my WordPress site?

Thanks

  • You can just place the html into the wordpress editor and it'll work, why not do that? – admcfajn Jan 31 '18 at 0:10
  • That is a way to add simple html code to the page, but I have multiple external html files I would to add directly into Wordpress. – pfiguer1 Feb 1 '18 at 16:51
  • what about adding a custom field for the html-file name(s) or even full-paths and using .load() of file_get_contents() to load the contents into the page template? There's plenty of ways to add custom fields to wordpress, I use ACF a lot personally. And a custom page-template or post-type single template is simple to do too. – admcfajn Feb 1 '18 at 17:31
  • @admcfajn That makes sense, is it similar to doing. <?php include 'path-to-the-html-file/html-file.html'; ?> ? – pfiguer1 Feb 1 '18 at 17:46
  • bingo, yeah foreach($custom_files as $file){ include $file } or thereabouts – admcfajn Feb 1 '18 at 20:06
1

It would really help to know exactly what you're trying to achieve. The more you work with WordPress, the more the sentence "Necessity is the mother of invention" makes sense.

A WordPress site is essentially snippets of html code put together with php. For example, header.php contains the instructions to build the header, the page template has the instructions for the body and footer.php has the instructions for the footer. I say they contain the instructions, because they usually hook into other functions to build the whole section.

Because of that, you wouldn't be able to take an entire html page with its own head, body and footer and just put it in WordPress.

Depending on what you are trying to do, the 3 most common ways to "import" html are:

1- You can paste html code in the WordPress editor with the "Text" tab in the top right, as opposed to "Visual" which is a WYSIWYG editor.

2- PHP is made to work with html so you can add the html code directly into your .php files (ideally with a child theme). The simplest way to display html with php is usually with echo.

3- If it's a page design, you can make a PHP version of it, put it in the template folder and use that as a page template in WordPress.

  • These are all good options for adding simple html to a Wordpress post/ page, but I have multiple external html files I would to add directly into Wordpress. I have multiple html files with plain html code and I want to store them on our site (i.e. domain.com/file.html). Then we'd like to "include" this on a page in WordPress (i.e. site-a.com/file would include the html code from domain.com/file.html). The reason I want to embed the files content is because there is CSS that must also apply. Any ideas? – pfiguer1 Feb 1 '18 at 17:01
  • Ok now I understand what you're trying to do. You could do it with iframe or via a modal window. You can find details on that here: wordpress.stackexchange.com/questions/69760/… – BenoitLussier Feb 1 '18 at 18:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.