While developing a website with WordPress, you’ve probably been or will be in the following situation: You created a Child Theme, inheriting a number of page templates from the parent theme. The thing is, maybe you don’t want some of those page templates. You don’t want your users to select it, or you’re not gonna support it, or it’s not fully compatible with the modifications you’ve made, or you just simply don’t like it. Whatever the reason is, you’d like to remove it from the dropdown in the page editor when creating a new page. Before WordPress 3.9, there were some bizarre and pretty much complicated things to accomplish this. However, wlth the introduction of the theme_page_templates filter, it has become a really easy task to do. So let’s say you want to remove a page template called “Full Width”, and the corresponding file is named template-full-width.php. In order to do this, you just need to add some code like the following in the functions.php file of your Child Theme: So that’s it. Hope it helps :) Further reading
Share This