您可以像这样在自定义循环中注册一个新的小部件
<?php
add_action( \'widgets_init\', \'Miy_widget_box\' );?>
<?php function Miy_widget_box() {
register_widget( \'Miy_Widget\' );
}?>
<?php class Miy_Widget extends WP_Widget {
public function __construct() {
// widget actual processes
parent::WP_Widget(false,\'Title Widget\',\'description=Description Widget\');
}
public function form( $instance ) {
// outputs the options form on admin
echo \'include html coding in here\';
}
public function update( $new_instance, $old_instance ) {
// processes widget options to be saved
}
public function widget( $args, $instance ) {
}
}?>