2 replaced http://wordpress.stackexchange.com/ with https://wordpress.stackexchange.com/
source | link

Ok I found a solution thanks to this: http://wordpress.stackexchange.com/questions/73956/using-wp-dropdown-categories-in-widget-optionsUsing wp_dropdown_categories in widget options

Here is the code I used instead:

function form( $instance ) {
    /* Default Widget Settings */
    $defaults = array(
        'title' => 'Highlight Category'
    );
    $instance = wp_parse_args( (array) $instance, $defaults ); 
?>

    <!-- Widget Title -->
    <p>
        <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'thstlang') ?></label>
        <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" />
    </p>

    <!-- Category Select Menu -->   
    <p>
        <select id="<?php echo $this->get_field_id('kwtax'); ?>" name="<?php echo $this->get_field_name('kwtax'); ?>" class="widefat" style="width:100%;">
            <?php foreach(get_terms('category','parent=0&hide_empty=0') as $term) { ?>
            <option <?php selected( $instance['kwtax'], $term->term_id ); ?> value="<?php echo $term->term_id; ?>"><?php echo $term->name; ?></option>
            <?php } ?>      
        </select>
    </p>
<?php 
}

Ok I found a solution thanks to this: http://wordpress.stackexchange.com/questions/73956/using-wp-dropdown-categories-in-widget-options

Here is the code I used instead:

function form( $instance ) {
    /* Default Widget Settings */
    $defaults = array(
        'title' => 'Highlight Category'
    );
    $instance = wp_parse_args( (array) $instance, $defaults ); 
?>

    <!-- Widget Title -->
    <p>
        <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'thstlang') ?></label>
        <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" />
    </p>

    <!-- Category Select Menu -->   
    <p>
        <select id="<?php echo $this->get_field_id('kwtax'); ?>" name="<?php echo $this->get_field_name('kwtax'); ?>" class="widefat" style="width:100%;">
            <?php foreach(get_terms('category','parent=0&hide_empty=0') as $term) { ?>
            <option <?php selected( $instance['kwtax'], $term->term_id ); ?> value="<?php echo $term->term_id; ?>"><?php echo $term->name; ?></option>
            <?php } ?>      
        </select>
    </p>
<?php 
}

Ok I found a solution thanks to this: Using wp_dropdown_categories in widget options

Here is the code I used instead:

function form( $instance ) {
    /* Default Widget Settings */
    $defaults = array(
        'title' => 'Highlight Category'
    );
    $instance = wp_parse_args( (array) $instance, $defaults ); 
?>

    <!-- Widget Title -->
    <p>
        <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'thstlang') ?></label>
        <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" />
    </p>

    <!-- Category Select Menu -->   
    <p>
        <select id="<?php echo $this->get_field_id('kwtax'); ?>" name="<?php echo $this->get_field_name('kwtax'); ?>" class="widefat" style="width:100%;">
            <?php foreach(get_terms('category','parent=0&hide_empty=0') as $term) { ?>
            <option <?php selected( $instance['kwtax'], $term->term_id ); ?> value="<?php echo $term->term_id; ?>"><?php echo $term->name; ?></option>
            <?php } ?>      
        </select>
    </p>
<?php 
}
1
source | link

Ok I found a solution thanks to this: http://wordpress.stackexchange.com/questions/73956/using-wp-dropdown-categories-in-widget-options

Here is the code I used instead:

function form( $instance ) {
    /* Default Widget Settings */
    $defaults = array(
        'title' => 'Highlight Category'
    );
    $instance = wp_parse_args( (array) $instance, $defaults ); 
?>

    <!-- Widget Title -->
    <p>
        <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'thstlang') ?></label>
        <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" />
    </p>

    <!-- Category Select Menu -->   
    <p>
        <select id="<?php echo $this->get_field_id('kwtax'); ?>" name="<?php echo $this->get_field_name('kwtax'); ?>" class="widefat" style="width:100%;">
            <?php foreach(get_terms('category','parent=0&hide_empty=0') as $term) { ?>
            <option <?php selected( $instance['kwtax'], $term->term_id ); ?> value="<?php echo $term->term_id; ?>"><?php echo $term->name; ?></option>
            <?php } ?>      
        </select>
    </p>
<?php 
}