• Resolved jrcollins

    (@jrcollins)


    I’m trying to access a widget’s settings from outside the widget code.
    The name of the widget is: category_grid, and the name of the option is; widget_categories.

    I tried the following code which was suggested in an answer to another question but it doesn’t return anything.

    <?php
    $options = get_option( 'widget_category_grid' );
    $cats = $options['widget_categories'];
    echo $cats;
    ?>
    • This topic was modified 8 years, 6 months ago by jrcollins.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @jrcollins,

    Did you check if $options is actually holding an array filled with values?

    Thread Starter jrcollins

    (@jrcollins)

    Hi @tsure, I got this to work by using the following code:

    $widget_instances = get_option('widget_category_grid'); 
     $catsin = $widget_instances[2]['widget_categories'];

    I just needed to find the ID of the widget. In this case “2”.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to get widget settings?’ is closed to new replies.