There’s a fundamental misunderstanding here about how partials/templates that aren’t full pages/template fragments in WP work.
get_*
is not how files are loaded, and get_header
and get_footer
are special cases for legacy reasons, kept for conventions sake.
They’re actually equivalent to:
get_template_part( 'header' );
get_template_part( 'footer' );
But with some additional filters and checks so that older code doesn’t break. ( see here )
So the answer would be:
get_template_part( 'myown' );
Only do this for templates though, if you have a library or PHP file that defines functions, classes, anything other than a template, use the standard PHP require
and include
statements.
(I don’t want to use do_shortcode())
Usually when people ask this question, they have actual pages with content that they want to embed code into, say halfway down a blog post, or at the top of a page. Shortcodes allow this to happen, which is why they’re a very common answer. But if you’ve defined a shortcode, you don’t need to call do_shortcode()
, just call the function directly.