-1

I'm working on a custom template for WordPress. I've created some page and then created the relative page-{slug}.php (example page-careers.php) that are supposed to be loaded from WordPress when the name of a page match. The problem is that it will load the index.php file and will not recognize the pages template I've made. I've checked the permalink settings and it's setted up with /%postname%/ inside the database and with the article name inside the WordPress options menu. How I can solve this?

  • post your page-careers.php code please – RiddleMeThis Jan 21 at 15:07
  • the code is correct, the only problem is that wprdpress 4.9.9 didn't recognize it as a page template and I needed to rename it. – ZWPDev Jan 21 at 18:24
0

If the page is supposed to display a list of posts check if your Wordpress back end has that page selected as the default posts page. If it is then change the default page to nothing or another page.

  • Hi Brett! Can you provide some documentation or examples of what you're talking about? – MikeNGarrett Mar 19 at 21:36
-1

Are you sure its loading the index.php file?

Template Hiearchy

  • custom template file
  • page-{slug}.php
  • page-{id}.php
  • page.php
  • singular.php
  • index.php

As you can see the index.php file would be last on the list. Double check the permalink URL setting on the page is correct. Then double check the file is named correct. page-test.php. As a test you could also try using the page ID like page-123.php.

enter image description here

  • I know about the template hierarchy, I was using wordpress when I started developing websites, since 2009. The problem is that wordpress doesn't recognize the page-careers.php and other words that can be used to create a page template. I've noticed that by renaming the page-careers into page-recruitments.php and the page template magically was loaded. This is why wordpress sucks. – ZWPDev Jan 21 at 18:23
-1

Permalinks only affect your Post and Category templates: https://codex.wordpress.org/Using_Permalinks

Double check that you created a Page and not a Post.

If you're still having problems, try restarting your local server.

  • OK... Why do you think that restarting server may help? Could you explain this advice? – Krzysiek Dróżdż Jan 21 at 19:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.