I'm currently experiencing a very strange issue which I can't find any reason to it.

I have a theme which is working fine on all servers. Now, I have one client who is having issues with it. The problem is that the function get_page_template_slug() returns the theme folder name.

Ex: theme/template-home.php

It should be just template-home.php without the theme folder name. How can this be?

Hope someone could help me out.

1 Answer 1


I just checked what the function you called does and it just retrieves the _wp_page_template value from the wp_postmeta table of WordPress. So probably the structure of your theme is not right, some rewrites are active, or something else (e.g. plug-in) altered this database table.

You could check that the theme root directory is indeed the directory which you think it is.

Other things that could be happening are:

The filename of a Page's assigned custom template is stored as the value of a Custom Field with a key named '_wp_page_template' (in the wp_postmeta database table). If the template is stored in a Theme's subdirectory (or a Parent Theme's subdirectory of a Child Theme), the value of the wp_postmeta is both the folder and file names

Which I got from here: https://codex.wordpress.org/Function_Reference/get_page_template_slug

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.