Four Ways to Edit HTML in WordPress
Use the method that matches the scope. A snippet inside one page is a block. Header, footer, and sidebar HTML is a widget or a template part. Theme files belong in a child theme, not in the post.
| Method | Use it for | You are done when |
|---|---|---|
| Custom HTML block | An embed, form, or button inside one page | Preview shows the embed, then Update is saved |
| Edit as HTML | A fix to one existing block | Edit visually shows the block with no invalid-content warning |
| Code editor | Markup across many blocks on one page | Exit code editor and every block is still listed |
| Classic Text tab | A post on the Classic Editor or a Classic block | The Text tab holds the tags and Visual does not show them as text |
| Widget or Site Editor | Sidebar, header, or footer HTML | The public page shows the snippet outside the post |
| Child theme template | header.php, single.php, or a block template | A parent theme update leaves your copy in place |
Administrators on a single WordPress site can save script and iframe tags. Authors and Contributors cannot. Lower roles lose those tags on save, which is the filter described later on this page.
Method 1: The Custom HTML Block
The Custom HTML block holds an embed, form, or button inside one page. Paste the fragment only. A full document with html, head, and body tags does not belong here.
- In wp-admin, open Pages or Posts and edit the page.
- Click the block inserter (+) and choose Custom HTML.
- Paste the markup for that embed only. Do not paste a full document.
- Click Preview on the block. You should see the embed, not the tags.
- Click Update, then open the public page in a private window so a cached copy does not hide the change.
Preview should show the embed, not the raw tags. If the public page drops the embed after Update, the account that saved it is not allowed to store that tag. Save again as an Administrator on a single site before you add another plugin.

Method 2: Code Editor and Edit-as-HTML Mode
Edit as HTML changes one block. Code editor changes every block on that page. On the Classic Editor, or inside a Classic block, the Text tab is the same control.
- Open the page in the block editor. Select one block, open its three-dot menu, and choose Edit as HTML.
- Change that block's tags, then choose Edit visually. The block should render. If WordPress says the block has invalid content, undo. Do not use Attempt recovery unless you can read the two versions it shows.
- For the whole page, open the three-dot Options menu at the top right and choose Code editor. Each block sits inside a comment such as <!-- wp:paragraph -->.
- Leave those comments in place. Removing a comment removes that block when you exit the code editor.
- Choose Exit code editor, click Update, and reload the public page in a private window.
- If the Classic Editor plugin is on, or you inserted a Classic block, open its Text tab, paste the HTML there, and click Update. Do not paste tags into the Visual tab.
You are finished when Edit visually shows a normal block and the public page matches the preview.
Method 3: Header and Footer HTML (Plugins and Hooks)
Sitewide header and footer tags do not go in a post. A classic theme uses a Custom HTML widget. A block theme uses a Custom HTML block in the Header or Footer template part.
- Classic theme: open Appearance, then Widgets. Click the inserter and add Custom HTML to the sidebar or footer.
- Paste the snippet, open the widget Preview, and click Update. Load a page that shows that widget area.
- Block theme: open Appearance, then Editor. Select the Header or Footer template part, add a Custom HTML block, and click Save.
- A tracking snippet can stay in that header spot. You do not need a theme PHP file for one script tag.
A WordPress-to-HTML converter only exports static files, and an HTML-to-WordPress converter only imports a static site. Neither one edits HTML inside this screen. The author name is under Users, then Profile. A static front page is under Settings, then Reading.
Method 4: Child Theme Templates (Safe Theme Edits)
Theme HTML belongs in a child theme. Editing the parent in Appearance, then Theme File Editor, is wiped on the next theme update, and a PHP typo can blank the site.
If Theme File Editor is missing, wp-config.php has DISALLOW_FILE_EDIT, or the user cannot edit themes. Treat that as a lock. Copy the template into a child theme and change the copy in the hosting file manager after a backup. The setup steps are on the WordPress child theme page.
The file lives under wp-content/themes/, inside the child theme folder, not the parent folder. Download it, edit it locally, upload the same filename, then view a page that uses that template.
Why WordPress Strips Some HTML (Sanitization)
WordPress runs post HTML through kses on save unless the user has the unfiltered_html capability. On a single site only Administrators have it. Editors, Authors, and Contributors do not, so script, iframe, form, style, and onclick are removed when they click Update.
On Multisite, a site Administrator does not have unfiltered_html either. A Super Admin does. The Custom HTML block can look right while you type, then the saved post loses the tag. View the page logged out. If the embed is gone, it was not stored.
This is not a cache problem. A private window still shows the stripped page because the tag never reached the database.
Fixing a Site Broken by HTML Edits
Undo an invalid block before you click Update. If the public page is already wrong, open Code editor and put back any wp: comments you deleted, or restore an older copy from the page Revisions panel.
- White screen after a theme file edit: stop saving. Open the hosting file manager and put back the previous template from your backup.
- With no backup, rename the active theme folder under wp-content/themes/. WordPress loads a default theme and the dashboard returns.
- Email support@webji.services with the file name and the exact error text. That mailbox is staffed 24/7 in Hindi and English. The office phone is not the support line.
These edits run on the host that already serves the site. If the site is moving to WebJi, start at WordPress hosting and wait for migration approval before you change theme files. To change words and images only, use edit WordPress content and leave the HTML alone.
Frequently Asked Questions
How do I edit the HTML of a WordPress page?
Open the page, choose Edit as HTML on one block or Code editor for the whole page, then click Update. Check the public URL in a private window so cache does not hide the result.
Where is the HTML editor in the Gutenberg block editor?
Select the block and open its three-dot menu, then choose Edit as HTML. For the whole page, open the top-right Options menu and choose Code editor.
How do I edit my theme's HTML without breaking updates?
Copy the template into a child theme and edit that copy. A parent-theme update replaces files you changed inside the parent.
Can I paste raw HTML into WordPress posts?
Yes. Paste it into a Custom HTML block or the Code editor, not into a paragraph block. Leave out the html, head, and body tags from a full document.
How do I edit the header and footer HTML?
On a classic theme, add a Custom HTML widget under Appearance, then Widgets. On a block theme, open Appearance, then Editor, and edit the Header or Footer template part.
Why did WordPress strip or break my HTML?
Users without the unfiltered_html capability lose script, iframe, form, and style tags on save. Single-site Administrators keep them. On Multisite, a site Administrator usually does not.

