WordPress.org

Ready to get started?Download WordPress

Forums

Custom page templates not recognised with permalinks on (6 posts)

  1. nicole2292
    Member
    Posted 1 year ago #

    Hello,

    I have been working with wordpress for a long time and I fully understand the template heirachy. I have some custom page templates page-about.php and page-projects.php for my about and projects pages.

    These were working perfectly earlier, however for a few reasons I needed to wipe my wordpress database and start again. I didn't change any of the theme files but after re-installing wordpress I now cannot get the new site to recognise these templates if permalinks is enabled.

    With permalinks off the templates are picked up on the relevant pages but as soon as I enable permalinks these pages just pick up the default page.php template.

    I have never seen anything like this before.

    Does anyone have any ideas?

    I have already tried enabling a different template and then re-enabiling my one, uninstalling and reinstalling my template and also rebuilding the permalinks... nothing has working...

  2. nicole2292
    Member
    Posted 1 year ago #

    Ok now I'm really tearing my hair out. I tried a work-around of adding
    Template Name: projects
    and
    Template Name: about
    to these templates and specifically selecting them for the relevant pages in the admin panel.

    Even with them specifically selected they are still not showing the right template files.

    I have also noted that projects is using the page.php template
    while about is actually using the default posts template and is not showing the about page content but rather the hello world post!!

    What on earth is going on?

    I have also tried all the permalink options and if I choose "numeric" it works however for all the others (which I actually want to use) it doesn't.

    This is so strange...

  3. cinghaman
    Member
    Posted 1 year ago #

    can you pastbin your template code file, + printscreen of your permalinks, and your htacess file

  4. nicole2292
    Member
    Posted 1 year ago #

    htaccess is stock standard

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress

    permalinks are just the standard post name /%postname%/ although I have tried other settings.

    The page-about.php file is working when permalinks are off so I don't see how this could be the problem. Also I have tried just using the page file and renaming with no changes to page-about.php but still this page is defaulting to use the index.php template.

    I have change the way the projects is done as I have a custom post type called projects and I thought this was the problem. Now it uses the file archive-projects.php this was working at first when I created it and now has suddenly stopped.

    I have reinstalled about 5 times and it seems sporadic when it does and doesn't work but once it stops working reinstalling is the only solution. Where are the permalinks actually stored? And if they are not stored why do we need to 'rebuild' them sometimes?

    It may be worth noting that I have a home page which uses page-home.php and is assigned as the static front page and this page template is working... just none of the others are...

    Very strange indeed!

  5. nicole2292
    Member
    Posted 1 year ago #

    Phew after an extremely lengthy investigation I have been able to identify that this is direclty related to the fact I had a custom taxonomy called "year". Year is already used by wordpress in the permalinks and this was causing all the problems.

    I have now had to rename my custom taxonomy. So it is no longer year.

  6. cinghaman
    Member
    Posted 1 year ago #

    :) good to know you came to a solution

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.