Custom page template to sidebar/widget

Use a shortcode include plugin and simply add a shortcode inside a text widget in the sidebar you’ll be using on the widgets or customizer page.

Here are some example plugins and how they work:

Include Me
[includeme file=”filename.php”]

Custom Content Shortcode[load file=template/sidebar.html]

Insert Pages Plugin[insert page="{slug}|{id}" display='title|link|content|all|{custom-template.php}']

Include Shortcode[include slug="hello-world"]


You could also simply duplicate the template and rename it to sidebar-{pagename}

Duplicate page template, remove commented header inside the file, and rename it sidebar-custom.php.

Then just include that inside the other page template where you want to use it.

<?php get_sidebar ('custom'); ?>

Other methods if you don’t want to rename add another file just include it in your template like a sidebar:

(will return template-name.php)

include ('template-name.php'); 

(will return template-name.php)

include(get_query_template('template-name'));

(will return template-name.php)

locate_template(template-name.php, true);

(will return content-page.php)

get_template_part( 'content', 'page' );