...

View Full Version : Sidebar problem after adding Page Boxes to functions.php



sohopigeon
06-28-2010, 05:02 PM
Hi All,

I want to include page boxes not only on my Home Page but other pages too. So I've updated the first few lines in my functions.php file from:



<?php
if ( function_exists('register_sidebar') ) {
register_sidebar(array(
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>',
));
}
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'Homepage Boxes',
'before_widget' => '<div class="homepage-box">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
?>


to



<?php
if ( function_exists('register_sidebars') ) {
register_sidebars(array(
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>',
));
}
if ( function_exists('register_sidebar') ) {
register_sidebar(array(
'name' => 'Homepage Boxes',
'before_widget' => '<div class="homepage-box">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
}
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'Page Boxes',
'before_widget' => '<div class="page-box">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
?>


the problem I have is my sidebar text widgets now have an h2 heading not h3...

I don't use h2 anywhere else in the site so I could simply change the stylesheet, but I would rather understand the cause of the problem.

I presume my change to functions.php has somehow caused the problem but I am not sure how. If you have an idea please let me know.

I notice that there is both register_sidebars and register_sidebar (no 's'), I've added an extra register_sidebar. I'm not sure what affect this has.

thank you for continued support developing this site

Kind regards

Will

sohopigeon
06-28-2010, 06:32 PM
Ok I solved my own post, I thank myself, here's the answer for those interested.

First I found this, which answers why the h2:

"The default before/after values are intended for themes that generate a sidebar marked up as a list with h2 titles. This is the convention we recommend for all themes and any theme built in this way can simply register sidebars without worrying about the before/after tags. If, for some compelling reason, a theme cannot be marked up in this way, these tags must be specified when registering sidebars. It is recommended to copy the id and class attributes verbatim so that an internal sprintf call can work and CSS styles can be applied to individual widgets." http://codex.wordpress.org/Function_Reference/register_sidebar

then I changed register_sidebars to register_sidebar (no 's') in the change I made to functions.php, and it fixed the problem.

:-)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum