This one has me stumped.
I have a page named ‘Login.’ I also have a file uploaded in my theme directory called ‘page-login.php’.
If I select a default theme template, page-login.php executes like it should. However, when I use a custom template that I created for modal use, page-login.php does not execute.
This is my custom template:
<?php
/*
* Template Name: Modal
* Author: Me
* URL: myurl.com
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="MSSmartTagsPreventParsing" content="true" />
<meta http-equiv="Imagetoolbar" content="No" />
<title>Email A Friend</title>
<style type="text/css">
body {font-size:13px;}
</style>
<link rel='stylesheet' id='gforms_css-css' href='<?php bloginfo('url'); ?>/wp-content/plugins/gravityforms/css/forms.css?ver=1.6.2.1.1' type='text/css' media='all' />
<script type='text/javascript' src='<?php bloginfo('url'); ?>/wp-includes/js/jquery/jquery.js?ver=1.7.1'></script>
<link rel="stylesheet" href='<?php bloginfo('stylesheet_directory'); ?>/style.css' type="text/css" media="screen" />
</head>
<body class="email">
<div id="emailForm">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
<?php wp_footer(); ?>
</div>
</body>
</html>
Don’t name your custom page template files
page-{foobar}.php
. Doing so will cause just this conflict with the Template Hierarchy for static pages:Which means that, if you assign a custom page template to the page, WordPress will use that, first and always.
Solution:
page-login.php
astemplate-login.php
Template Name: Login Page
totemplate-login.php
Login Page
template to your static page named “Login”