• Skip to content
  • Skip to primary sidebar
  • Skip to footer

Foliovision

Main navigation

  • Weblog
    • FV Player
    • WordPress
    • Video of the Week
    • Case Studies
    • Business
  • About
    • Testimonials
    • Meet the Team
    • We Support
    • Careers
    • Contact
    • Pricing
  • Products
  • Support
    • FV Player Docs
    • Pro Support
  • Login
  • Basket is empty

How to create and hide template identifiers

Knowing which template file you are working is the first major hurdle that the designer runs into when working with the php files. This is what a ftp listing of a WordPress theme looks like.

A list of Wodpress theme files

With this labyrinth of various PHP files with similar names, how on earth is an honest designer to know what file he or she should be working? Browsing the front end of the site, you have no idea what you are looking at most of the time.

Am I working on archives.php or archive.php? Is this index.php or home.php?

Well the first thing to do is to open up all the files in the template folder and have a look at them.

Selectable templates which you can choose as a template for your page while editing have this code at the very top of the file:

<?php
/*
Template Name: Archives
*/
}
?>

WordPress needs this unique name to manage your extra templates. Each file with a name like this will be a selectable template in this list when creating or editing a page:

Changing page template in Wordpres

Default WordPress template files (i.e. single.php, page.php, archive.php) don’t have that comment and must be present in every theme.

But even this identifier doesn’t help you when browsing the site to know which pages are running off each template.

It’s easy enough to just drop some html in the source code and it will show up and tell you what template such and such page is using.

But the problem with the simple solution is that everyone who visits your site will see your “Yo – Analysis Template” and wonder why it’s there.

There is an easy way to solve this, although it took some searching to find the solution.

Instead of adding just straight text or a paragraph, add this instead:

<?php if ( $user_ID ) { ?><p class="templateinfo">Template = Archives</p><?php } ?>

The ideal place I’ve found for the identifier code in my templates is between the header and the content block:

Put in the conditional code with template name here

After that I apply these styles to the base css file:

p.templateinfo, p.sidebarinfo {font-size: 8px; color: gainsboro;}
p.templateinfo {float: left;}

The sidebarinfo class is there to cover the situation when you have multiple sidebars (Foliovision does). The float left on p.templateinfo may or may not work for your own template. It works great on mine.

In the sidebar files I recommend adding the code at the bottom of the sidebar:

<?php if ( $user_ID ) { ?><p class="templateinfo">Template = Archives</p><?php } ?>

With this done, as you browse your site logged in you will know at all times exactly what file you are looking at. So if you don’t like it is a trival matter to go in and make adjustments.

Here’s what the end result looks like:

Example of a WordPress page with page template name displayed for logged in users

and for the sidebar.php:

Template name in the sidebar

You can save up to five or ten minutes confusion per edit with these simple additions to your template file.

And your visitors don’t even need to be aware of the under construction signs everywhere.

Setting template identifiers up only takes about ten minutes. They make editing a WordPress template faster and a lot more fun.

Reader Interactions

Comments

  1. Jeroen Nevers 29 January 2012 at 6:26 am

    Thanks.

    Really clever idea.

    I was doing the exact same thing you describe: Typing a string of text in every template.

    So now I know how to handle this properly

    Cheers

    Reply
  2. wdhppr 30 August 2018 at 6:15 pm

    Suppress Template by copying it into child theme and removing comment/header content:

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You can click here to Subscribe without commenting

Primary Sidebar

How to Hack a WordPress Theme

  1. StudioPress Tutorials
  2. WordPress Tutorial Videos for Foliovision Clients
  3. WordPress Plugins
  4. Shared.css Framework
  5. WordPress How To Guides
    1. How to Hack a WordPress Theme
      1. How to create and hide template identifiers
      2. Front End Editing
    2. How to alter WordPress comment email
    3. How to reorder pages
    4. How to create your own filled-in extension
    5. Lost your password in WordPress?
    6. How to Comment Code in WordPress Templates
  6. WordPress Plugin Reviews

Footer

Our Plugins

  • FV WordPress Flowplayer
  • FV Thoughtful Comments
  • FV Simpler SEO
  • FV Antispam
  • FV Gravatar Cache
  • FV Testimonials

Free Tools

  • Pandoc Online
  • Article spinner
  • WordPress Password Finder
  • Delete LinkedIn Account
  • Responsive Design Calculator
Foliovision logo
All materials © 2025 Foliovision s.r.o. | Panská 12 - 81101 Bratislava - Slovakia | info@foliovision.com
  • This Site Uses Cookies
  • Privacy Policy
  • Terms of Service
  • Site Map
  • Contact
  • Tel. ‭+421 2/5292 0086‬

We are using cookies to give you the best experience on our website.

You can find out more about which cookies we are using or switch them off in .

Powered by  GDPR Cookie Compliance
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

Necessary Cookies

Strictly Necessary Cookie allow you to log in and download your software or post to forums.

We use the WordPress login cookie and the session cookie.

If you disable this cookie, we will not be able to save your preferences. This means that every time you visit this website you will need to enable or disable cookies again.

Support Cookies

Foliovision.com uses self-hosted Rocket.chat and self-hosted Freescout support desk to provide support for FV Player users. These cookies allow our visitors to chat with us and/or submit support tickets.

We are delighted to recommend self-hosted Rocket.chat and especially Freescout to other privacy-conscious independent publishers who would prefer to self-host support.

Please enable Strictly Necessary Cookies first so that we can save your preferences!

3rd Party Cookies

This website uses Google Analytics and Statcounter to collect anonymous information such as the number of visitors to the site, and the most popular pages.

Keeping this cookie enabled helps us to improve our website.

We reluctantly use Google Analytics as it helps us to test FV Player against popular Google Analytics features. Feel free to turn off these cookies if they make you feel uncomfortable.

Statcounter is an independent Irish stats service which we have been using since the beginning of recorded time, sixteen years ago.

Please enable Strictly Necessary Cookies first so that we can save your preferences!