WordPress.org

Support

Support » How-To and Troubleshooting » Altering .php files

Altering .php files

  • I want to make changes to some .php files on my domain, but I was just wondering whether any changes I made directly to these files would be lost if the theme I am using is reinstalled or updated. At the moment I am using a child theme with a style.css that imports the code for the style.css in the parent theme, but is it possible to do the same with .php files and just make a sidebar.php in my child theme and import the code from the sidebar.php from the parent theme, for example?

    Sorry if I’m not explaining myself very well or I’m asking a stupid question, but I’m new to all this.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Jan Dembowski

    @jdembowski

    Brute Squad and Volunteer Moderator

    I was just wondering whether any changes I made directly to these files would be lost if the theme I am using is reinstalled or updated.

    If you modified core files and/or parent theme files, yes the changes would be lost when an update happens.

    At the moment I am using a child theme with a style.css that imports the code for the style.css in the parent theme, but is it possible to do the same with .php files and just make a sidebar.php in my child theme and import the code from the sidebar.php from the parent theme, for example?

    Not import, but make duplicate copies of the parent theme files that you want to modify and put those copies into your child theme directory.

    As long as the files are standard template file names or loaded via get_template_part() then your child theme’s copies will be loaded instead of the parent theme copies.

    http://codex.wordpress.org/Child_Themes#Template_files

    Sorry if I’m not explaining myself very well or I’m asking a stupid question, but I’m new to all this.

    Nope, it’s all good. 🙂

    Thanks Jan, that’s really helped. 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Altering .php files’ is closed to new replies.
Skip to toolbar