WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Removing page template from child theme. (3 posts)

  1. Richard Coan
    Member
    Posted 3 years ago #

    I currently creating a child theme based off of another theme, how do you remove a parent page template from the page template selection without destroying it from the parent?

  2. Richard Coan
    Member
    Posted 3 years ago #

    Well after some reading I'm guessing there is no way to do this. Time for plan B, Merge Child with Parent and delete the unnecessary templates...

  3. Tom Auger
    Member
    Posted 2 years ago #

    This technique will do what you're looking for.

    Here is Rarst's code, verbatim:

    add_action('admin_head-post.php','remove_template');
    
    function remove_template() {
    
        global $wp_themes;
    
        get_themes();
        $templates = &$wp_themes['Twenty Ten']['Template Files'];
        $template = trailingslashit( TEMPLATEPATH ).'onecolumn-page.php';
        $key = array_search($template, $templates);
        unset( $templates[$key] );
    }

    Obviously, this goes into your plugin .php file or your functions.php file...

Topic Closed

This topic has been closed to new replies.

About this Topic