Forums

How to properly remove template pages from a theme (6 posts)

  1. scott
    Member
    Posted 5 months ago #

    I make child themes based on the 2011 Theme. I often want to remove some pages, such as "author.php", and this is easy - just delete them from both the child and the parent theme. However when 2011 gets updated, the author.php file will get added again.

    There must be functions that allow you to set pages that WP will ignore, such as category archives, or author pages. Basic unique templates are easy to remove, but core pages don't seem to be easy.

    In any case I would like to remove them properly, and know that future upgrades and updates won't undo my work.

  2. bheadrick
    Member
    Posted 5 months ago #

    put this in your child theme's functions.php

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Then for each page template you want to remove, call remove_template like so:

    function remove_parent_templates() {
        remove_template( array( "showcase.php", "sidebar-page" ) );
    }
  3. scott
    Member
    Posted 5 months ago #

    Thanks for the detailed reply. I tried this and threw "author.php" into the function to be removed, but it still exists.

    My assumption is that this only works for page.php style templates, that are listed when you create a new page, and not core WP files such as author.php or tag.php.

    If it only works with page templates it's still really useful!

  4. ferguson8673
    Member
    Posted 5 months ago #

    My question is, how do you create tabs in here. I have looked in help and troubleshooting and a lot of blogs amd forums and I cannot find any info. in how to create different tabs. Our business wants certain tabs with names that we choose.

  5. bheadrick
    Member
    Posted 5 months ago #

    ok, just so we're on the same page,
    A) the author.php is in the parent theme and not the child theme
    B) you still have an author archive

    correct?

  6. scott
    Member
    Posted 5 months ago #

    Yes, there is no "author.php" in my child theme, just in the 2011 Theme.
    I am still getting an author archive page. I don't get this if I physically remove the author.php file from the 2011 theme (which is a bad method.)

    Here is what I used to remove two templates:

    function remove_parent_templates() {
    remove_template( array( "showcase.php", "author.php" ) );
    }

    I will look again at my functions.php again, because I am including some of the 2011 set up functions to over-ride them (if they are already set, 2011 won't set them). Perhaps something in there is affecting this.

Reply

You must log in to post.

About this Topic