小编Aka*_*rob的帖子

after_widget的致命错误

我试图创建一个简单的窗口小部件以显示特定类别的帖子列表,但出现错误日志,"Notice: Undefined index: after_widget in"
我还注意到一个奇怪的事情,我的窗口小部件<aside>类使所有其他窗口小部件成为其子级,她没有关闭完成小部件代码后,

这是我的代码:

if ( !defined('ABSPATH') )
	die('-1');
	
	
add_action( 'widgets_init', function(){
     register_widget( 'news_roller' );
});	

function illu_news_widget(){

        wp_enqueue_style( 'your-stylesheet-name', plugins_url('/css/style.css', __FILE__), false, '1.0.0', 'all');
    }
    add_action('wp_enqueue_scripts', "illu_news_widget");

/**
 * Adds news_roller widget.
 */
class news_roller extends WP_Widget {

	/**
	 * Register widget with WordPress.
	 */
	function __construct() {
		parent::__construct(
			'news_roller', // Base ID
			__('News roller', 'isas_news'), // Name
			array( 'description' => __( 'News roller', 'isas_news' ), ) // Args
		);
	}

	/**
	 * …
Run Code Online (Sandbox Code Playgroud)

php wordpress widget wordpress-plugin

0
推荐指数
1
解决办法
646
查看次数

标签 统计

php ×1

widget ×1

wordpress ×1

wordpress-plugin ×1