Wordpress ignoring page template from drop down

1.4k views Asked by At

I am struggling with something that appears to be easy, page templates. I have read plently posts on this, people seem to forget to put the comment at the top of the page and can't get it to show up in the drop down menu on pages. I can do this, my problem is the next stage.

I have written the most basic template (custom-page.php):

<?php
/*
Template Name: Test template
*/
?>


<?php get_header(); ?>

<h1>Teams!</h1>

<?php get_footer(); ?>

It shows up and I can select it on the new page sidebar. However when I visit that new page it seems to have defaulted the archive page using the content template include.

Thanks in advance.

2

There are 2 answers

1
murdaugh On

If you put the following in your footer, you should be able to grok some further information about how your template is being selected (and know exactly what might be happening).

<?php global $template;
echo(basename($template)); ?>

Then look for the template name in your footer. It's possible (like @adomnom said) that you have a slug conflict. There are a handful of other strange scenarios that could be caused by plugins, custom functions, or other factors as well.

1
adomnom On

By the sounds of things, it could be conflicting with another template.

For example, if your page has the slug 'category' and is set to use the custom template 'custom-template.php', it would conflict with (and be overridden by) category.php, which is the default template for showing posts for a specific category.

I recommend changing the slug to see if that's the problem.