Sam.d93
Sam.d93

Reputation: 39

What are the wordpress core files and why they should not be edited?

Is "functions.php" a core file? What if I want to add a functionality without using any plugin?

I am very new to wordpress and PHP

Upvotes: 0

Views: 2218

Answers (3)

Sajid Manzoor
Sajid Manzoor

Reputation: 1428

Wordpress Core files or Core files in Wordpress can be divided into two sub categories

  1. Wordpress Core Files

  2. Wordpress Plugin/Theme Core Files

1- Wordpress Core Files are the files that are combined together to make Wordpress work and run on an environment. These files should not be modified or deleted in any Case. Complete Wordpress installation or instance is based on these files. If any file among these is changed then it can break Wordpress or changes make Wordpress to behave abnormal. Another draw back of modifying these files is that if you modify these files then you will not be able to update Wordpress to latest version in future. If you do so then your changes will be overwritten by new Wordpress Update. Wordpress core files are located in following folders:

  • wp-admin
  • wp-includes
  • and files that are located in Wordpress installation root. These files includes index.php, and all other files whose names are starting with wp- prefix. You can only change wp-config.php file as it remains same in most of the releases.

2- Wordpress Plugin/Theme Core Files are the files that are part of any specific plugin or Theme that you have bought or downloaded from Wordpress directory. You should try not to change these files. Modifying these files will not break your Wordpress installation or instance. But if you modify these files then your changes will be over written by future plugin or theme version updates. These files are located in wp-content/plugins and wp-content/themes directory. In order to modify your theme, you should create a Child theme based on your parent theme. If you want to modify a plugin, please create another plugin and override the plugin functionality using hooks. You can also over ride plugin functionality by writing code in theme's functions.php

And last thing 'functions.php' file inside your theme directory is not a Wordpress core file.

Upvotes: 2

RustyBadRobot
RustyBadRobot

Reputation: 566

Simple answer is "functions.php" is not a core file. WordPress 'core' files are what makes up the WordPress framework e.g. basically everything you get when you download WordPress https://github.com/WordPress/WordPress The reason these files should not be edited is because in future WordPress updates they could be overwritten and you would lose your changes.

You should expand WordPress functionality with plugins or themes and this is where the functions.php file comes in as each theme has a functions.php file. But it's not as straight forward as this.

If you are using a premium theme or one which you have not developed let's say it's called "Rusty's Theme" then that themes functions.php will be a core file to that theme and ideally you should create a child theme with it's own functions.php to extend the functionality for the same reason, the theme's updates could overwrite your edits.

p.s. I think this is a valid question.

Upvotes: 2

Johannes
Johannes

Reputation: 67778

Usually you wouldn't edit the functions.php file, since next time the theme is updated, the file will be replaced by the updated one and your edit will be gone.

The common way - even if you only want to make a few changes - is to create a child theme and in there only use the files you want to change - for all others WP will use the parent theme files. (Note: The minimum you need is a style.css file, but it can just contain additional styles - all other CSS rules will be taken from the parent theme.)

More about child themes here: https://developer.wordpress.org/themes/advanced-topics/child-themes/

Upvotes: 1

Related Questions