0

I have a widget for displaying my site's categories on the frontpage. The widget admin form has a checkbox list of categories for controlling the widget output. What's the best way to retrieve the saved values from the category selection? The data is saved as $instance['widget_categories']. So, I want to retrieve the category id's and then use them in the include parameter of the get_categories() array.

0
$wg_class = new Widget_Toggle_Title();
$settings = $wg_class->get_settings();

print_r($settings);

Replace Widget_Toggle_Title class with yours.

  • I think you might have misunderstood the question. – jrcollins Sep 17 '16 at 4:39
0

The answer to this question is very simple:

$catsin = $instance['widget_categories'];
$child_categories = get_categories( array(
  'orderby' => 'id',
  'hide_empty' => 0,
  'include' => $catsin
) );

This is what I originally tried to do but I made the basic error of enclosing the variable in quotes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.