404 on custom pages
-
i am completely stumped on this, i’m hoping i am missing something obvious. here is the situation:
i have a page in the database with the slug ‘banks’. in the page.php file of my theme, i have the following:
if (str_starts_with($_SERVER[‘REQUEST_URI’], ‘/banks/’))
{
require(TEMPLATEPATH . ‘/page-templates/page-template-institutions.php’);
exit;
}switch($_SERVER[‘REQUEST_URI’])
{
case ‘/banks’:
require(TEMPLATEPATH . ‘/page-templates/page-template-institutions.php’);
exit;
…
}in page-template-institutions.php i generate the content for the requested page, based on the actual url (eg, /banks or /banks/bank-name). this works flawlessly, both for the urls ‘/banks’ and ‘/banks/bank-name’.
then i added another page in the database with the slug ‘credit-unions’. i added the same logic to page.php to handle relevant urls:
if (str_starts_with($_SERVER[‘REQUEST_URI’], ‘/credit-unions/’))
{
require(TEMPLATEPATH . ‘/page-templates/page-template-institutions.php’);
exit;
}switch($_SERVER[‘REQUEST_URI’])
{
case ‘/credit-unions’:
require(TEMPLATEPATH . ‘/page-templates/page-template-institutions.php’);
exit;
…
}when i request the url ‘/credit-unions’, it works perfectly, and i get the generated content. however, when i request a url like ‘/credit-unions/credit-union-name’, i get a 404 page not found.
the logic seems to be identical between banks and credit-unions, but for some reason wordpress is doing something different with urls that begin with ‘/credit-unions/…’ than it is with urls that begin with ‘/banks/…’. i cannot find anywhere in my code that would account for that. am i missing something in this scenario?
any useful ideas GREATLY appreciated. thanks in advance.
- The topic ‘404 on custom pages’ is closed to new replies.