Where do I save widget code for wordpress?
I've googled around quite a lot, but can't seem to find where I should be saving the code for the widget I've created. It's a bit baffling.
So, can anyone tell me where I should save my widget?
Thanks, John.开发者_JAVA技巧
You need to put your widget code in either the functions.php file of your current theme, or within a plugin. In order to put it in a plugin, create a new folder in the plugins folder and create a .php file with the name of the folder you created within that folder. In that file, use this code to start your plugin:
<?php
/*
Plugin Name: Name Of The Plugin
Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates
Description: A brief description of the Plugin.
Version: The Plugin's Version Number, e.g.: 1.0
Author: Name Of The Plugin Author
Author URI: http://URI_Of_The_Plugin_Author
License: A "Slug" license name e.g. GPL2
*/
?>
Obviously, change the values to something useful for your plugin. You can then paste your widget code into this file and it should be ready to use.
Sources:
http://codex.wordpress.org/Writing_a_Plugin
http://codex.wordpress.org/Plugin_API
As far as I know, widget (ie plugins) go in your wp-content/plugins folder eg. wp-content/plugins/YOUR WIDGET/
Is that what you need?
You can save your code in the file of wp-content\themes\YOUR-THEME-NAME\functions.php.
精彩评论