Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Hiding page templates WordPress


I have created a variety of page templates for my site. Two of these templates are for a specific purpose - one gets applied to the homepage, the other to a contact page. Is it possible to hide my ‘Homepage’ and ‘Contact’ templates from WordPress’s template list (Page Properties > Templates) once they have been associated with their respective pages?

Basically, once these templates have been associated with the relevant pages, I don’t want the user to accidentally associate further pages with either of these templates.

Answers (2)


Navjot Singh answers:

Easiest way to hide them after associating them is to remove the top comment lines from the corresponding template's php file. That way it won't be recognized as template anymore and won't show in the drop-down list again.

designbuildtest comments:

Perfect. Thanks Navjot.

Navjot Singh comments:

You still haven't voted for me?

designbuildtest comments:

Hi Navjot, originally I thought this was the perfect answer to my problem but unfortunately this method does not work.

If the user subsequently makes an update to either the Homepage or Contact us page, the applied template is lost and the page reverts to the default WordPress page template (page.php).

Any suggestions for an alternative solution?



Fakhri Setiawan answers:

yes, use this plugin :

designbuildtest comments:

Not what I'm looking for sorry Fakhri. I need a simple function that can be dropped into functions.php rather than a full-blown plugin. Thanks.