treehouse : what would you like to learn today?
Web Design Web Development iOS Development

using css to create new widgets.

  • I am new to css and HTML but does anyone know how to create custom widgets that I add to my wordpress site www.thetop40.com Check it out and let me know what you think.
  • you cannot make a widget out of css. you can only change its appearance.
    In case you might want to make a new widget, you must first register a new widget at function.php and add a another code in the desired area where you want your widget to be located.

    code for registering widget in function.php
    	register_sidebar( array(
    'name' => __( 'Your Widget Name', 'theme' ),
    'id' => 'div-id-for-widget',
    'description' => __( 'Your Widget Name', 'theme' ),
    'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    'after_widget' => '</li>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
    ) );


    here is the code for the desired area
    <?php if ( is_active_sidebar( 'div-id-for-widget' ) ) : ?>
    <div id="div-id-for-widget" class="widget-area">
    <ul class="xoxo">
    <?php dynamic_sidebar( 'div-id-for-widget' ); ?>
    </ul>
    </div>
    <?php endif; ?>

    you can always modify the code to your liking
    btw, nice site. only that there is a missing image in your header section. might be a logo or something.