How to get individual values from custom widget?
I have the following custom sidebar:
I want to know if it's possible to get the values stored in each widget individually. I already tried doing the following:
global $wp_registered_widgets;
$widgets = wp_get_sidebars_widgets();
echo pre;
var_dump($widgets['footer-1']);
foreach ($widgets['footer-1'] as $widget) {
var_dump($wp_registered_widgets[$widget]);
}
echo /pre;
But the first var_dump
only returns:
array(5) {
[0]=
string(10) nav_menu-2
[1]=
string(6) text-2
[2]=
string(6) text-3
[3]=
string(6) text-4
[4]=
string(6) text-5
}
And the var_dump
inside the foreach
only returns this properties:
array(7) {
[name]=
string(4) Menu
[id]=
string(10) nav_menu-2
[callback]=
array(2) {
[0]=
object(WP_Nav_Menu_Widget)#4570 (9) {
[id_base]=
string(8) nav_menu
[name]=
string(4) Menu
[option_name]=
string(15) widget_nav_menu
[alt_option_name]=
NULL
[widget_options]=
array(3) {
[classname]=
string(15) widget_nav_menu
[customize_selective_refresh]=
bool(true)
[description]=
string(41) Add a menu to your widget area.
}
[control_options]=
array(1) {
[id_base]=
string(8) nav_menu
}
[number]=
int(2)
[id]=
string(10) nav_menu-2
[updated]=
bool(false)
}
[1]=
string(16) display_callback
}
[params]=
array(1) {
[0]=
array(1) {
[number]=
int(2)
}
}
[classname]=
string(15) widget_nav_menu
[customize_selective_refresh]=
bool(true)
[description]=
string(41) Add a menu to your widgets area.
}
I need what's inside of each widget. So for the texts, I need to retrieve what's stored in the textarea
. Is this possible?
Topic widget-text widgets Wordpress
Category Web