Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

derick renwick
derick renwick
3,555 Points

Widgets work but will not "save" (choices are lost on refresh)

Widgets work but will not "save" (choices are lost on refresh) . I followed the directions regarding building a wordpress theme's widgets (custom widget area). The code works and correctly implements the code in the correct place. However, whenever the admin>appearance>widgets page is refreshed the choices(widgets) are lost. This is the code added to my functions.php //ADDING WIDGETS

function create_widget( $name, $id, $description){

$args = array(
    'name'      => __( $name ), //dynamic name for widgets
    'id'        => $id, //widgets id
    'description' => $description, //widgets description
    'before_widget' => '',
    'after_widget'  => '',
    'before_title'  => '<h5>',
    'after_title'   => '</h5>'
) ;

register_sidebar( $args ); //registers args array for widgets. This collects the information needed to display widgets

}

//call this function to create new widget areas. The name Id and Description in that order need to be stated in the create_widget Array create_widget('Sidebar', 'sidebarWidget', 'sidebar widget area'); HELP IS GREATLY APPRECIATED