I’ve created a WordPress template for a page. The template is called koebenhavn.php. It’s located in a subdirectory in my themes directory. The code looks like this:
<?php
/*
Template Name: Koebenhavn
*/
?>
<?php get_header(); ?>
<?php
query_posts('cat=3');
while (have_posts()) : the_post();
the_content();
endwhile;
?>
<?php get_footer(); ?>
When I go to the Admin-panel and choose the page, which I want to use this template on, and I press the blue “Update”-button, it switches back to “Default Template” automatically. I’ve never experienced this before.
I’ve tried adding the template on already existing pages as well as newly created pages.
Just to be clear, you are going to an existing page AND selecting the template before hitting update? I see nothing wrong with the code itself outside of some extraneous tagging, none of which relates to your problem but I’ll paste the cleaned up code below.
I would suspect this is a file permission problem since it is visible in one sense (wordpress can read it) but not in another (wordpress cannot seem to ‘execute’ it).
Alternatively, there could be a problem within the database, other plugins, and so on. Generally it’s a good practice to disable all plugins and test to see if the anomaly repeats itself despite that.
The reason for this behaviour was caused by the name of the file. I was using the Danish letter, ø, in the filename
københavn.php
.There’s probably a way to work around this, but for the easy way out, just write
koebenhavn.php
instead.