Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save landru247/5453855 to your computer and use it in GitHub Desktop.
Save landru247/5453855 to your computer and use it in GitHub Desktop.
WordPress: PHP - register custom widgets
// register custom widgets
if ( function_exists('register_sidebar') )
{
register_sidebar(array(
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widget title">',
'after_title' => '</h2>',
'name' => 'widget-1',
'id' => 'widget-1'
));
}
// Prints widget
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('widget-1') ) : ?>
<?php endif; ?>
// register custom widgets
if ( function_exists('register_sidebar') )
{
register_sidebar(array(
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widget title">',
'after_title' => '</h2>',
'name' => 'widget-1',
'id' => 'widget-1'
));
}
// Prints widget
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('widget-1') ) : ?>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment