Actually i have deployed a wordpress running website on my local environment. I want to have some general instruction that how can i know which file points to which url. Like if i entered the url mysite.com/household-insrtuments. it opens a page in the backend i searched from the text through the project i found that this opens the file name 'housing-facilities.php' so is there any way i can view this ?

  • That kind of URLs are rewrited to index.php at server-level; all other needed files are included form there. Your question is a bit confusing. Can you try to elaborate it? – cybmeta Jul 11 '17 at 12:15

Wordpress has a template hierarchy, he search down the files in your theme until he finds a suitable template for the content hes outputing following the hierarchy.

Here it's a example from de Codex:

If your blog is at http://example.com/blog/ and a visitor clicks on a link to a category page such as http://example.com/blog/category/your-cat/, WordPress looks for a template file in the current theme’s directory that matches the category’s ID to generate the correct page. More specifically, WordPress follows this procedure:

  1. Looks for a template file in the current theme’s directory that
    matches the category’s slug. If the category slug is “unicorns,” then WordPress looks for a template file named category-unicorns.php.
  2. If category-unicorns.php is missing and the category’s ID is 4, WordPress looks for a template file named category-4.php.
  3. If category-4.php is missing, WordPress will look for a generic category template file, category.php.
  4. If category.php does not exist, WordPress will look for a generic archive template, archive.php.
  5. If archive.php is also missing, WordPress will fall back to the main theme template file, index.php.

Here's a image that shows the complete hirarchy:

Wordpress template hierarchy

He will follow this behaviour unless you rewrite it with the Rewrite API.

In your case house-facilities.php is a Custom Template, and household-instruments is a page that uses this custom template, go to your Admin -> Pages -> Household Facilities and edit it, on the edit page you will see in the right corner a block called Page Attributes, inside that block has a select called Template and you will see that House Facilities Index is selected.

So what happens? As described in the link above, if you want to create a template for multiple pages to use, you can create a file and register it as an template. To register a file as a template simply put a comment in the top of the file with the line, Template Name: My Template, now in the edit page, you can select that file to output any page as you want.

When I'm developing a theme I like to use the Show Current Template plugin to see which files the page is loading.

Too learn about the template hierarchy see the Theme handbook.

  • i have not seen any kind of files there which you have mentioned. When i click on the href link it opens the mysite.com/household-insrtuments. just this not any kind of id or unicorn. when i search and changed the text on the housing-facilities.php file it changed the text on the url so it means it was pointing out the housing-facilities.php file. but i am not getting it how to know each url – tech_geek Jul 11 '17 at 12:25
  • That is just an example of how the template system works in wordpress, I can't say the exacly files of your theme because I don't know him and don't know if you're using, taxonomies or custom post types, if he has template for them etc. I showed you an example e posted de link for the Codex so you can learn how it works a figure out. And you can also use the plugin, just install it and when you visit a page, will list all the files loaded for that page in the admin bar. – Cesar Henrique Damascena Jul 11 '17 at 12:36
  • for the plugin suggestion Thank you for that it is really helping. but still i did not find my question's answer. I thought that there would be a particular pattern in the wordpress to followed for the files. – tech_geek Jul 11 '17 at 12:57
  • And it does, it's the pattern that I explained to you above, he sees if the content it's an Post Type, Taxonomy, Page etc.. and search for a template to output it following the hiararchy in the image. So household-instruments could be a Custom Post Type and house-facilities.php be a template for this post type or it could be a term or a taxonomy, It's hard to know when I can't see your files and don't know what household-instruments is. That's why I explained how the template system in wordpress work, so you can study it and figure out. – Cesar Henrique Damascena Jul 11 '17 at 13:08
  • actually if this url is calling house-facilities. there should be a link to it. I have searched both that from where it is linking these two but i have only found the string coccurences not as a particular link. So i can assume that these could be in database? – tech_geek Jul 11 '17 at 13:21

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.