My widget was like this:
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";
}
Below works as a new widget without overriding the default wordpress recent posts
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";
}
to not override default recent post the only thing i have to do is not name it as ‘recent-posts’ on this line: parent::__construct( 'recent-posts', __( 'Recent Posts' ), $widget_ops );
.
The error was there.
see more details at: https://codex.wordpress.org/Widgets_API