Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Making a site for a client, I have some pages that the client won't be able to edit or delete. These pages rely on specific page templates.

However, I don't want these templates to be available for the client when creating new pages. Is there someway to hide these certain page template from the page attributes dropdown when creating new pages?

Thanks

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

Rather than defining them as custom page templates, you have an alternative.

Use the page specific templates, e.g. for a profile page, with the slug profile you could create a page-profile.php in your theme, or you can use page-21.php where 21 is the ID of that page/post.

share|improve this answer
    
Good interim solution, but too bad so sad if you wanted a custom_file_name.php... –  userabuser Oct 9 '12 at 13:10
    
Indeed, though there are methods of removing the need for a post altogether, but I haven't the research to back it up in a comprehensive answer at the moment –  Tom J Nowell Oct 9 '12 at 13:31
add comment

Sorry, but this is not (longer) possible (as the page_template filter seems to have been removed with the introduction of the WP_Theme class).

The get_templates_dropdown() function that calls the templates inside the meta box calls get_page_templates() which then has this builder function inside:

wp_get_theme()->get_page_templates()

And this function comes without any sort of filter or hook.

share|improve this answer
    
So I'm left with manually fetching setting in the DB? Or what are my options? –  INT Oct 9 '12 at 11:38
    
You could maybe rebuild that meta box, unregister the original one, register your own, add your changes to the core function and copypaste that into some custom plugin. –  kaiser Oct 9 '12 at 11:56
    
This could not be done in PHP, but as the admin is already full of jQuery, maybe you could just use jQuery to dynamically change the DOM of the admin page, removing one item from the dropdown menu. –  Simon Oct 9 '12 at 20:09
    
@Simon "This could not be done in PHP(...)" this is nonsense. –  kaiser Oct 9 '12 at 22:12
    
@kaiser : could you explain me in a few word why, considering that there is no simple way of doing it with any built-in function, it's perfect nonsense to do it with jQuery - considering this is not a public-wide modification but will only be used in one instance for a particular individual ? –  Simon Oct 10 '12 at 7:44
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.