Skip to content

Instantly share code, notes, and snippets.

@joshuadavidnelson
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshuadavidnelson/58209a7320638d740414 to your computer and use it in GitHub Desktop.
Save joshuadavidnelson/58209a7320638d740414 to your computer and use it in GitHub Desktop.
Remove parent page templates from dropdown option in child theme pages
<?php
/**
* Removes parent theme page templates from the dropdown option on add new/edit page screen.
*
* Note that the path/to/ is from the parent theme directory, so if the page templates are in a subdirectory add that path,
* otherwise it can be written as 'page-template.php'
*
* @author Joshua David Nelson, josh@jdn.im
*/
add_filter( 'theme_page_templates', 'jdn_remove_page_templates' );
function jdn_remove_page_templates( $templates ) {
unset( $templates['path/to/page-template1.php'] );
unset( $templates['path/to/page-template2.php'] );
unset( $templates['path/to/page-template3.php'] );
unset( $templates['path/to/page-template4.php'] );
return $templates;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment