我的小部件是这样的:
public function __construct() {
$widget_ops = array(
\'classname\' => \'yggdrasil_widget_recent_entries\',
\'description\' => __( \'Your site’s most recent Posts.\' ),
\'customize_selective_refresh\' => true,
);
parent::__construct( \'recent-posts\', __( \'Recent Posts\' ), $widget_ops );
$this->alt_option_name = \'yggdrasil_widget_recent_entries\';
}
以下是一个新的小部件,无需覆盖默认的wordpress最近发布的帖子
public function __construct() {
$widget_ops = array(
\'classname\' => \'yggdrasil_widget_recent_entries\',
\'description\' => __( \'Your site’s most recent Posts.\' ),
\'customize_selective_refresh\' => true,
);
parent::__construct( \'yggdrasil-recent-posts\', __( \'Yggdrasil Recent Posts\' ), $widget_ops );
$this->alt_option_name = \'yggdrasil_widget_recent_entries\';
}
要不覆盖默认的最近发布,我唯一要做的就是不要在此行中将其命名为“最近发布”:
parent::__construct( \'recent-posts\', __( \'Recent Posts\' ), $widget_ops );
.
错误就在那里。
有关更多详细信息,请访问:https://codex.wordpress.org/Widgets_API