Finding the template used to build a WordPress page.
Is there a way to tell from a WordPress page what template the page was built from. In my case, there's a page at mysite.com/checkout and I happen to know that the template used to build this page is at wp-content/plugins/woocommerce/templates/checkout/form-checkout.php. But how could I have known that just from poking around the page with Chrome Dev Tools?
Thanks
WordPress
Last Comment
Jason C. Levine
8/22/2022 - Mon
Jason C. Levine
If you have access to the admin login for the site, sure.
From looking at just the front end? You should be able to get a clue from the body class. This is what one of mine looks like (template bolded for emphasis):
I didn't see and Editor option under Appearance in the Dashboard.
But in any case, thinking more about my question, I don't think it's possible see anything in a browser that will tell you what template was used to build some portion of a page, say a checkout form. Those templates are all consumed by the PHP and what you see on the browser is the result of following the template instructions.
Jason C. Levine
I don't think it's possible see anything in a browser that will tell you what template was used to build some portion of a page, say a checkout form
It depends on exactly how the page or application is built. Some will be as you say, others will use a more straightforward approach like my sample. It's not a black and white issue. For WooCommerce, clearly it's the former.
I didn't see and Editor option under Appearance in the Dashboard.
Either you don't have full administrator privileges (e.g. someone messed with the capabilities) or you're logging in as an editor.
eemit
For custom page templates, you can see page template name (not page template file name) in:
Edit Page Screen / Template or in
Pages / Quick Edit / Template
Pages / Quick Edit / Template shows "Default template" for most all my pages but I know that the checkout page, for example, is built from many templates controlling various area of the page and its those templates that I wanted to find. But as I mentioned above, I don't think this is going to be possible because those templates were "consumed" by PHP to create the page and no trace of them is left by the time the browser displays the results.
From looking at just the front end? You should be able to get a clue from the body class. This is what one of mine looks like (template bolded for emphasis):
<body class="page page-id-44821 page-parent page-template page-template-template-hea