I have a widget that is saving an option perfectly – the problem lies when I want to get the option value on the front end and then use that value to query the posts. How can I get that value from the database? I’ve tried using get_option and because the way the value is stored the array position changes each time.
My code is simply:
$cjd_length = get_option( 'widget_cjd_list_widget' );
if( !empty( $cjd_length[3]['length'] ) ) {
$length = $cjd_length[3]['length'];
}
else {
$length = 3;
}
In the method WP_Widget::widget($args, $settings) you get the Widget Settings. From outside you must know the widget-id. You get it in the update Method ($_REQUEST[‘widget-id’])