How to make certain page templates visible to admin only

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?

Read More

Thanks

Related posts

Leave a Reply

2 comments

  1. 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.

  2. 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.