Skip to content

Instantly share code, notes, and snippets.

@jsonberry
Last active February 19, 2016 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsonberry/fdf19ff945487af638c2 to your computer and use it in GitHub Desktop.
Save jsonberry/fdf19ff945487af638c2 to your computer and use it in GitHub Desktop.
WordPress -> Custom Widget Function. Add to functions.php.
<?php
function create_widget($name, $id, $description)
{
register_sidebar(array(
'name' => __( $name ),
'id' => $id,
'description' => __( $description ),
'before_widget' => '<div id="'.$id.'" class="widget %1$s %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>'
));
}
create_widget("Header", "uptop", "Displays in the header of the site, above the title");
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment