I am trying to make wordpress load a specific static php file(not a page template) for wordpress pages.
For example, for the contact page i would like to load the already done contact.php.
I tried adding in functions.php something like:
if( is_page('careers')){
get_page('careers.php');
}
or
function get_pages() {
if(is_page('careers')) {
return get_template_uri() . '/careers.php';
}
}
What am I missing?
EDIT: I’ve managed to load the pages by renaming them to page-careers.php, page-contact.php, and so on.
I tried your solutions but I had no success.
Try this for include PHP file
And get another page content
Get template part is usually used for retrieving template files like you are trying to do. See more here: https://developer.wordpress.org/reference/functions/get_template_part/
So, for example in your code above, if you had a file called contact.php in your theme folder that you wanted to include, you could use the following code: