Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

ganeshrnet on "Filter out the active widget array list - Wordpress"

$
0
0

I am stuck with something in WordPress. I was looking for the answer for this question everywhere possible but couldn't find what I wanted to know.

I have made a widget in the WordPress admin widget page and I want to use this widget data somewhere else in the website. I used the function $data = get_option('widget_data'); to retrieve the data of the widget. Since WordPress supports multiple instances of a widget, the values are stored in database as an array and the output of the code gave me this array list :

array (size=4)
  2 =>
    array (size=3)
      'title' => string 'Notice 0' (length=14)
      'page_id' => string '9472' (length=4)
      'desc' => string '1' (length=1)
  3 =>
    array (size=3)
      'title' => string 'Notice 1' (length=14)
      'page_id' => string '9594' (length=4)
      'desc' => string '1' (length=1)
  4 =>
    array (size=3)
      'title' => string 'Notice 2' (length=16)
      'page_id' => string '9594' (length=4)
      'desc' => string '1' (length=1)
  '_multiwidget' => int 1

The problem is: When I remove an instance of the widget from the widget holder the data used by that deleted widget is not flushed out and because of this I can't understand whether or not to use the data data from array.

My question is: Is there anyway to understand whether the widget instance is still active or not? As you can see that there is no indication or value to understand which all instances are active at the moment and which are not active. Please guide me..

Warm Regards :)


Viewing all articles
Browse latest Browse all 8245

Trending Articles