Widgets (entry valid for WordPress v2.2.2) – In this version are already integrated Widgets for the sidebar, we will look more closely at how to use them and we will describe how to correctly styles using CSS. The theme directory you have a file functions.php to open it, right from the start is the definition of what will happen before and after the widget, the widget title.

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="widgettitle">', 'after_title' => '</h2>',

1) If you are ok with the fact that all elements of the sidebar will be styling a single definition, adjust the following settings and enter the definition of the class .bar to file style.css.

.bar {	padding: 5px 5px 5px 5px;
	background: url('images/bar.jpg') no-repeat;
	color: White;
  }
if ( function_exists('register_sidebar') )
register_sidebar(array(
'before_widget' => '<div class="bar">',
'after_widget' => '</div>', 'before_title' => '<h2>',
'after_title' => '</h2>',
));

Now check out folder /wp-includes/ and open file widgets.php and put above changes here too:

$defaults = array(
'name' => sprintf(__('Sidebar %d'), $i ),
'id' => "sidebar-$i",
'before_widget' => '<div class="bar">',
'after_widget' => '</div>',
'before_title' => '<h2>',
'after_title' => '</h2>',
);

2) If you need some elements sidebar stylish different definitions, we have to reflect how these settings in the file widgets.php as individual files of the widget plugins. The following is an example of the various functions of the file widgets.php directly modify, add CSS class .bar

function wp_widget_meta($args) {
	extract($args);
	$options = get_option('widget_meta');
	$title = empty($options['title']) ? __('Meta') : $options['title'];
?>
<?php echo $before_widget; ?>
<div class="bar"><?php echo $before_title . $title . $after_title; ?>
<ul><?php wp_register(); ?>
<li><?php wp_loginout(); ?></li>
<li><a href="<?php bloginfo('rss2_url'); ?>" title="<?php echo attribute_escape(__('Syndicate this site using RSS 2.0')); ?>"><?php _e('Entries <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
<li><a href="<?php bloginfo('comments_rss2_url'); ?>" title="<?php echo attribute_escape(__('The latest comments to all posts in RSS')); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
<li><a href="http://wordpress.org/" title="<?php echo attribute_escape(__('Powered by WordPress, state-of-the-art semantic personal publishing platform.')); ?>">WordPress.org</a></li>
<?php wp_meta(); ?>
</ul>
</div>
<?php echo $after_widget; ?>
<?php
}>

Similarly we do with external widgets, the only way we will be able, for example, Event Calendar to use a different class.

  /** Event Calendar widget. */
  function ec3_widget_cal($args)
  { extract($args);
    $options = get_option('ec3_widget_cal');
    echo '<div class="otherbar">';
    echo $before_widget . $before_title;
    echo ec3_default_string($options['title'],'Kalendář');
    echo $after_title;
    ec3_get_calendar();
    echo '</div>';
    echo $after_widget;
  }

David

Graphic and website designer, currently, I attend to the maintenance of about thirty sites for existing clients as well as creating websites for the new ones. In my free time, I get into the secrets of the world of Linux, SSH, WP-CLI and I’m preparing this blog.

More:

How to add WordPress Author Bio & Profile Pag... Today I will show you how you can integrate very nice Author Bio at the end of each article in your wordpress theme and more we take a look how to ma...
15 Beautiful Free WordPress Themes of 2011 Free WordPress Themes - Another part of the survey themes, which I encountered in my browsing, could be inspiration for someone. Bloggers are always i...
Homemade vector freebies, design tips, tutorials b... Photoshop is certainly the most powerful tool for editing photos, but critics have already pointed out the absence of a sufficient number of high qual...
Talisman Active Desktop v1.5 On the desktop we use super shell Talisman, we publish our theme Talisman Active Desktop, which we placed in the directory of themes that can be downl...
A Showcase of Creative Meet The Team Pages People very rarely want to do business with a faceless corporation. If you can show that there are actual people who work behind the scenes, then you ...

Newsletter

Join our mailing list to receive the latest news and updates.

You have Successfully Subscribed!

Pin It on Pinterest