Create a Function to Create WordPress Widgets

I’ve taken to the practice of doing something like this whenever I need to create multiple widgets in a theme that all have the same basic parameters.

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

		'name' => __( $name ),	 
		'id' => $id, 
		'description' => __( $description ),
		'before_widget' => ' ',
		'after_widget' => ' ',
		'before_title' => '<h5>',
		'after_title' => '</h5>'


create_widget("Left Footer", "left_widget", "Displays in the left of the footer");

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s