I have just created my first WordPress widget ("hello world" style) and was able to display it correctly. But what I notice that if I change my theme then my created widget disappears from available widget area in admin panel; though there are many widgets which are always showed regardless of chosen theme (Like Text widget). I want to know how can I make my widget available across all the themes?
-
is your widget code part of a theme or in a plugin?– MiloOct 14, 2013 at 17:02
-
@Milo Its actually in a theme. How can I create it as a plugin? Can you suggest any tutorial. Sorry I am newbie in wordpress coding.– ferdousxOct 14, 2013 at 17:19
1 Answer
Put all your custom widget code into a separate php file, add a plugin header:
<?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
*/
then upload it to your plugins directory and activate it. That's it!