For example I have in my theme folder named test-pages with some php web pages that display different message, in some part of process I want to pull with file_get_contents to get content of one page from that folder, but I can’t do it, it just doesn’t work, when I try to access directly to that page, I get 404 message like that pages doesn’t exists.
How can I make this page visible to WordPress, so I can access it without getting 404?
Hope you understand me.
Move the template files out of the subdirectory, and put them in the Theme’s root directory. Then, if you simply want to include the contents of those template files in other template files, simply call
get_template_part( 'test-page-name.php' );
.If you insist on keeping these files in a subdirectory, you’ll need to include them via
locate_template()
.The solution is here.
Simply go into the page template you want to edit and add this at the very top:
When you go into the admin area and edit the page you want, a dropdown list of page templates will appear in the right column that you can choose from.
Edit: If you have already done what I described above, and the problem persists, you might have a .htaccess issue. Another possibility is that you aren’t referencing the file correctly, so double check your declarations to make sure they are producing the correct file path and file name. Hope this helps you out!