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


Konrad Pilch
Konrad Pilch
2,435 Points

How to make a widget ?


How can i make a simple widget such as ' Displaying the most popular blogs' ? or even putting tags so it has more tags you can search for lol and so on.. ?

I mean , not this:

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

        'name' => __( $name ),   
        'id' => $id, 
        'description' => __( $description ),
        'before_widget' => '<div class="widget">',
        'after_widget' => '</div>',
        'before_title' => '<h4>',
        'after_title' => '</h4>'


create_widget( 'Front Page Left', 'front-left', 'Displays on the left of the homepage' );

But more like this ( i believe ):

<h2>Recent Posts</h2>
    $args = array( 'numberposts' => '5', 'tax_query' => array(
                'taxonomy' => 'post_format',
                'field' => 'slug',
                'terms' => 'post-format-aside',
                'operator' => 'NOT IN'
                'taxonomy' => 'post_format',
                'field' => 'slug',
                'terms' => 'post-format-image',
                'operator' => 'NOT IN'
    ) );
    $recent_posts = wp_get_recent_posts( $args );
    foreach( $recent_posts as $recent ){
        echo '<li><a href="' . get_permalink($recent["ID"]) . '">' .   ( __($recent["post_title"])).'</a> </li> ';