How to load a stylesheet in a WordPress widget?
function widget($args, $instance) { wp_enqueue_style( 'my-widget-style', plugins_url('style.css', __FILE__) ); } // widget()
by Rolf van Gelder | CAGE Web Design, Eindhoven
How to load a stylesheet in a WordPress widget?
function widget($args, $instance) { wp_enqueue_style( 'my-widget-style', plugins_url('style.css', __FILE__) ); } // widget()
How to create a basic Widget?
<?php /* * Plugin Name: Test Widget * Version: 0.1 * Description: This is a Test Widget * Author: Me * Author URI: http://me.com */ ?> <?php class TestWidget extends WP_Widget { /********************************************************************* * CONSTRUCTOR *********************************************************************/ public function __construct() { parent::__construct(false, $name = 'This is a Test Widget'); } // __construct() /********************************************************************* * DISPLAYS THE WIDGET *********************************************************************/ function widget($args, $instance) { extract($args); $html = 'Hey, this is a Test Widget!'; echo $html; } // widget() } // TestWidget /********************************************************************* * REGISTER THE WIDGET *********************************************************************/ add_action('widgets_init', create_function('', 'return register_widget("TestWidget");')); ?>