I'm new in wordpress theme development. I want to display recent posts via recent post widget. but when I active the Recent posts widget in wordpress admin panel it only shows the title but not the images. But when i write a custom code in sidebar it works fine. I want to work it like a widget perfection. I do not want to use any plugin, help me in custom code.
Have a look at the
WP_Widget_Recent_Posts class in
wp-includes/default-widgets.php to see how it is structured.
You can even copy and paste the class in your
functions.php, rename it to something else and modify the class to display your images.
And don't forget to add a
register_widget('NameOfYourClassHere'); hooked to