The theme is responsible for display, but does not involve functional changes. Otherwise, some functions will become invalid after the user switches themes.
This is why I have never seen a theme with a like function. It turns out that this should be a plug-in category.
Plugins are packages of code that extend the core functionality of WordPress. WordPress plugins are made up of PHP code and other assets such as images, CSS, and JavaScript.
The plug-in is responsible for adding functional logic. For example, a shopping cart plugin. Plugins can use their functionality after activation.
Add routine to create a new data table storage plug-in configuration
These operations are not recommended by the theme.
Custom Post Type
Since plug-ins are more suitable for functional expansion, the new Custom Post Type should theoretically be implemented in the plug-in. For example, create a new CPT in activation.
However, the question arises, if you use a plug-in to create a new CPT, where is the front-end display logic of the CPT implemented? If you implement it in a theme, there will be a problem that CPT disappears when you change the theme; if you implement it in a plug-in, it feels weird. . .
But judging from the example given in Working with Custom Post Types in the wordpress plugin handbook, the display of CPT is still in the plugin.
Where is the display logic written? Where is the functional logic written? The answer is not absolute.
For one-time functions with no reuse value, or temporary websites, you can write whatever you want. As long as it can go online quickly enough.
For more wordpress related technical articles, please visit the wordpress tutorial column to learn!
The above is the detailed content of The difference between wordpress themes and plugins. For more information, please follow other related articles on the PHP Chinese website!