Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
[WordPress] A simple example for how to include a template part from a plugin using `the_content` hook.
add_action( 'the_content', 'acme_add_template_part' );
function acme_add_template_part( $content ) {
require plugin_dir_path( dirname( __FILE__ ) ) . '/includes/templates/acme-my-template.php';
$template = ob_get_contents();
$content .= $template;
return $content;
* Template Name: Acme Template Part
* @since 1.0.0
<form action="#" method="post">
<label for="acme-firstname">First Name <span class="acme-required">*</span></label>
<input type="text" id="acme-firstname" name="acme-firstname">
<input type="submit" value="Submit">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.