
📄 How to embed an HTML file into a WordPress page: the Include Me plugin
We built a contact form in a separate .html, wrote a report script in PHP, and the WordPress editor mangles the code on every save? A familiar pain for anyone who goes beyond the standard block builder.
Include Me solves this task with a single shortcode line: it includes an external HTML/PHP file or the content of another post directly into the post body. The plugin lives in the WordPress.org directory with 4,000+ active installs, a 4.8 rating, and updates for WP 6.9.4. The author, Stefano Lissa, is the creator of Newsletter and Hyper Cache.
Below is a complete breakdown: from installation to passing variables to PHP scripts and secure iframe mode.
💡 Quick overview:
- Install Include Me from the WordPress.org directory (Plugins → Add New, search for "Include Me").
- Upload your target HTML/PHP file to the
/wp-content/include-me/folder on the server. - Insert the shortcode
[includeme file="your-file.html"]wherever you need it in a post or page. - For PHP files: the plugin will execute the script and output the result. For HTML, it inserts as-is.
- Alternatively, include another WordPress post via
post_idor an external URL via iframe syntax.
What is Include Me and when do you need it
Include Me is a lightweight plugin (just a few lines of code, according to the author) that solves a specific task: inserting an external file into the body of a WordPress post or page via shortcode.
When you need this in practice:
- Forms and calculators. You wrote an HTML form with CSS and JS, and the block editor corrupts the markup every time you switch between visual and text mode. Include Me inserts the file byte-for-byte, touching nothing.
- PHP reports. A script pulls data from the database, builds a table, and outputs HTML. Include Me executes the PHP and displays the result inside the post without editing the theme.
- Shared blocks. The same file (pricing table, disclaimer, contact block) needs to appear on a dozen pages. Edit the file once, and it updates everywhere automatically.
- Content from another post. You included text from another page via
post_id, and it stays in sync: edit in one place, display everywhere.
The main advantage over a custom theme template: when you change themes, your files stay in place. The theme changes, content lives independently.
Installation and first run
Installation is standard, through the WordPress admin panel:
- Plugins → Add New.
- In the search field, type "Include Me".
- Find the plugin by Stefano Lissa, click Install Now → Activate.
After activation, the plugin is ready to use with no settings screens. All "configuration" is done through shortcode syntax.
Default file path: /wp-content/include-me/. Upload files you plan to include to this folder. If you need a different directory, add to wp-config.php:
1 define('INCLUDE_ME_DIR', '/path/to/your/folder');
If you want to include files from anywhere on the server, set an asterisk (but it's safer to restrict to one folder):
1 define('INCLUDE_ME_DIR', '*');
Important security limitation: starting with version 1.3.0, the [includeme] shortcode only executes in posts owned by an administrator. Files are searched by default within the site's root folder (ABSPATH and below). This is not a bug but a safeguard: Include Me executes PHP code, and you should not give that capability to just anyone.
Basic syntax: including HTML and PHP files

The main shortcode is [includeme file="filename"]. It works in any post, page, or widget (via do_shortcode).
Example 1: HTML file. You prepared price-table.html with pricing layout and styles. You uploaded it to /wp-content/include-me/. In the post, you write:
1 [includeme file="price-table.html"]
The plugin reads the file and inserts its content exactly where the shortcode is placed. A <style> tag inside the file works. Inline JS works. No markup "sanitization."
Example 2: PHP script. The file report.php runs a SELECT from the database and outputs a table. The .php extension is the trigger for Include Me: the plugin does not just read the file but executes it via include. The script's output (echo/print) goes into the post:
1 [includeme file="report.php"]
Example 3: Relative path. A path without a leading slash (file="myfolder/data.html") is relative to the site root (ABSPATH). An absolute path (file="/var/www/external/widget.html") starts from the server's filesystem root. In most cases, you use a relative path to a file inside /wp-content/include-me/.
Including another post or page via post_id
The Include Me developers added syntax for pulling content from an existing WordPress post. The shortcode:
1 [includeme post_id="42"]
Where 42 is the numeric ID of the desired post or page. How to find the ID: in the admin panel, hover over the "Edit" link of the desired post, and you will see post=42 in the browser's status bar.
This technique is convenient for legal pages. Privacy policies or terms of use are often duplicated: one instance in the "parent" page, the rest use Include Me with post_id. The lawyer edits the text in one place, and it updates everywhere.
Note: only the post content is pulled, not the title. If you also need the title, you will have to duplicate it inside the content or use [includeme file="..."] with a PHP script that calls get_post().
Iframe mode: embedding an external URL
The third syntax generates an <iframe> instead of direct inclusion:
1 [includeme src="https://example.com/widget"]
Any additional attributes are passed to the <iframe> as HTML attributes:
1 [includeme src="https://example.com/widget" frameborder="0" width="600" height="450"]
The result is a full iframe with the specified dimensions. This is an alternative to direct inclusion for cases when:
- You need to show an external page as a "window" inside the post.
- The included content must live in an isolated context (its own CSS/JS that does not conflict with the theme).
- You need to embed an interactive widget (calculator, map) that should not execute in the WordPress context.
Limitation: iframe mode does not execute PHP; it simply displays the URL in a frame. For server-side code, use file="...".
Passing variables to PHP scripts
The most powerful feature of Include Me is passing parameters from the shortcode to the included PHP file. In the shortcode, you write:
1 [includeme file="greeting.php" name="Alexey" plan="Pro"]
Inside greeting.php, you access the attributes via the global $attrs array:
1 <?php 2 $user_name = $attrs['name'] ?? 'Guest'; 3 $user_plan = $attrs['plan'] ?? 'Free'; 4 5 echo "<p>Hello, {$user_name}! Your plan: {$user_plan}.</p>";
This turns Include Me into a mini templating engine. The same PHP file generates different output depending on the shortcode attributes. Practical scenarios:
- Price calculator. A single
calc.phpscript receivesbase_priceanddiscountfrom the shortcode, showing different calculations on different pages. - Personalized block.
cta.phpacceptsheadingandbutton_text, each post has its own headline and button, but the HTML skeleton is shared. - Client dashboard.
client-stats.phpreceivesclient_idand outputs data for a specific client from an external CRM.
What Include Me does not do: limitations
The plugin solves a narrow task and does not try to be a Swiss army knife. Drawbacks worth knowing before installation:
- Administrators only. The shortcode works only in posts authored by an administrator. Authors and editors cannot use Include Me; this is an intentional security restriction (version 1.2.2+).
- No visual editor. No UI in the admin panel: the plugin does not add a metabox for file selection. Everything is done manually via shortcode.
- The
.phpextension is required for execution. A file namedscript.incwith PHP code will NOT execute; the plugin will insert it as text. Rename it toscript.php. - No caching. Each shortcode call reads the file from disk or executes the PHP anew. For high-traffic pages with heavy scripts, cache the output yourself (via the Transients API or a page-level caching plugin).
⁉️🤔 Frequently asked questions
Does Include Me work with modern WordPress versions?
Yes, the plugin is tested up to WordPress 6.9.4 and requires version 6.1 or higher. The latest update (1.3.7) was released in February 2026, and the author maintains compatibility with each major WP release.
Is it safe to include PHP files via shortcode?
Since version 1.2.2, the plugin executes PHP files only from a folder inside the site root and only for administrator-authored posts. This prevents running arbitrary code via XSS or URL substitution. Additionally, restrict the folder via
define('INCLUDE_ME_DIR', '...')and avoid using'*'unless absolutely necessary.
How does Include Me differ from the Insert Pages plugin?
Insert Pages focuses on inserting content from other posts; it has a rich set of formatting and wrapper options. Include Me is simpler and designed for working with files: HTML, PHP, TXT. If your task is only to pull in another post, Insert Pages is more convenient. If you need PHP scripts and external files, Include Me is the choice.
Can I insert the same file on ten pages?
Yes, that is exactly what the plugin is designed for. One file in
/wp-content/include-me/is included via the same shortcode on any number of pages. Edit the file, and the content updates everywhere instantly without resaving each post.
Why does my PHP file output nothing?
Three common reasons: (1) the file is not in the
INCLUDE_ME_DIRfolder, and the path is incorrect; (2) a fatal error exists in the PHP code (checkWP_DEBUGand server logs); (3) the file was saved with an.htmlor.incextension instead of.php(Include Me only executes.php).
What if the plugin stops receiving updates?
Include Me consists of just a few lines of code (according to the author) and does not depend on external services. Even without updates, it will continue working for years; its logic is not tied to the WP REST API, blocks, or Gutenberg-specific features. The basic WordPress shortcode mechanism has not changed since version 2.5.
What to do if you need more: alternatives and next steps
If Include Me does not cover your needs, here are two directions for expansion:
- Inserting posts with formatting: the Insert Pages plugin pulls content from other posts with flexible display settings (title, excerpt, custom wrapper).
- Full PHP engine: the WPCode plugin (formerly Insert Headers and Footers) lets you insert PHP snippets globally or conditionally, with syntax highlighting and error control.
Start with Include Me: for the typical task of "insert an external file into a post," it is more than enough. And if you have already used this plugin or solved a similar task differently, share in the comments which tool you chose.



