Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action("widgets_init", array('my_widget_name', 'register')); | |
class my_widget_name { | |
function control(){ | |
echo 'ここに設定項目を入れる'; | |
} | |
function widget($args){ | |
echo $args['before_widget']; | |
echo $args['before_title'] . 'ウィジェットのタイトル' . $args['after_title']; | |
echo 'I am your widget'; | |
echo $args['after_widget']; | |
} | |
function register(){ | |
register_sidebar_widget('ウィジェット名', array('my_widget_name', 'widget')); | |
register_widget_control('ウィジェット名', array('my_widget_name', 'control')); | |
} | |
} | |
?> |
Screen shot
Note
Description | オリジナルのウィジェットを作成するための基本コード |
---|---|
WordPress Ver. | 3.3.1 |
Via | register a widget in function.php |